@clarify-labs/renderer 0.10.2 → 0.11.0
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/{ClarifyShell-C6li72Ce.cjs → ClarifyShell-BAjq876Z.cjs} +113 -90
- package/output/ClarifyShell-BAjq876Z.cjs.map +1 -0
- package/output/{ClarifyShell-1LuBliwt.js → ClarifyShell-GoSXvgMg.js} +114 -91
- package/output/ClarifyShell-GoSXvgMg.js.map +1 -0
- package/output/{MermaidViewer-B6-BMCJG.cjs → MermaidViewer-BZ8ghcFP.cjs} +2 -2
- package/output/{MermaidViewer-B6-BMCJG.cjs.map → MermaidViewer-BZ8ghcFP.cjs.map} +1 -1
- package/output/{MermaidViewer-dXsomvM7.js → MermaidViewer-CkIxyqtf.js} +2 -2
- package/output/{MermaidViewer-dXsomvM7.js.map → MermaidViewer-CkIxyqtf.js.map} +1 -1
- package/output/{OpenApiOperation-DgrqzeiS.js → OpenApiOperation-C2vJztWZ.js} +1983 -365
- package/output/OpenApiOperation-C2vJztWZ.js.map +1 -0
- package/output/{OpenApiOperation-B52IWlKb.cjs → OpenApiOperation-D-5uE5v7.cjs} +2009 -361
- package/output/OpenApiOperation-D-5uE5v7.cjs.map +1 -0
- package/output/{PageActions-BjB6PYmL.cjs → PageActions-DJRXlGhz.cjs} +532 -358
- package/output/PageActions-DJRXlGhz.cjs.map +1 -0
- package/output/{PageActions-D7K9LDGf.js → PageActions-bugd7GZh.js} +535 -361
- package/output/PageActions-bugd7GZh.js.map +1 -0
- package/output/{SearchDialog-CIPvXMT3.cjs → SearchDialog-8AdCRp6K.cjs} +3 -3
- package/output/{SearchDialog-CIPvXMT3.cjs.map → SearchDialog-8AdCRp6K.cjs.map} +1 -1
- package/output/{SearchDialog-CxYLjRi5.js → SearchDialog-CBJjDs_9.js} +3 -3
- package/output/{SearchDialog-CxYLjRi5.js.map → SearchDialog-CBJjDs_9.js.map} +1 -1
- package/output/app/ContentDiagnostic.d.ts +2 -1
- package/output/app/PageFooter.d.ts +1 -1
- package/output/client.cjs +3 -3
- package/output/client.js +3 -3
- package/output/components/AccordionGroup.d.ts +7 -0
- package/output/components/Collapse.d.ts +2 -0
- package/output/components/FileTree.d.ts +10 -0
- package/output/components/Image.d.ts +6 -0
- package/output/components/Steps.d.ts +12 -0
- package/output/components/Tabs.d.ts +12 -5
- package/output/components/Tooltip.d.ts +8 -0
- package/output/components/index.d.ts +10 -1
- package/output/core/i18n.d.ts +1 -1
- package/output/core/types.d.ts +37 -19
- package/output/{i18n-DnqZHFT7.js → i18n-BPrC45nD.js} +102 -2
- package/output/i18n-BPrC45nD.js.map +1 -0
- package/output/{i18n-b4iTLeia.cjs → i18n-wXINKKV0.cjs} +102 -2
- package/output/i18n-wXINKKV0.cjs.map +1 -0
- package/output/index.cjs +38 -8
- package/output/index.cjs.map +1 -1
- package/output/index.d.ts +8 -7
- package/output/index.js +34 -9
- package/output/index.js.map +1 -1
- package/output/mdx/components.d.ts +11 -1
- package/output/mdx/primitives.d.ts +4 -2
- package/output/openapi/components/CodeDisplay.d.ts +1 -0
- package/output/openapi/components/EndpointMethodBadge.d.ts +6 -0
- package/output/openapi/components/EndpointSections.d.ts +2 -2
- package/output/openapi/components/ExamplePanels.d.ts +2 -2
- package/output/openapi/components/InlineListbox.d.ts +31 -0
- package/output/openapi/components/OpenApiAuthPanel.d.ts +12 -0
- package/output/openapi/components/OpenApiOperation.d.ts +1 -9
- package/output/openapi/components/OpenApiOperation.state.d.ts +4 -2
- package/output/openapi/components/OpenApiRequest.d.ts +18 -0
- package/output/openapi/components/OpenApiRequestFields.d.ts +25 -0
- package/output/openapi/components/OpenApiResponseViewer.d.ts +8 -0
- package/output/openapi/components/SendRequestButton.d.ts +9 -0
- package/output/openapi/components/helpers.d.ts +6 -1
- package/output/openapi/components/useOpenApiRequestState.d.ts +41 -0
- package/output/openapi/entry.d.ts +2 -0
- package/output/openapi/index.d.ts +2 -2
- package/output/openapi/lib/api-exchange-code.d.ts +8 -0
- package/output/openapi/lib/api-exchange.d.ts +30 -0
- package/output/openapi/lib/api-request.d.ts +24 -0
- package/output/openapi/lib/request-code.d.ts +2 -2
- package/output/openapi/lib/request-parameters.d.ts +5 -0
- package/output/openapi/store.d.ts +10 -0
- package/output/openapi/types.d.ts +4 -0
- package/output/preview.cjs +37 -27
- package/output/preview.cjs.map +1 -1
- package/output/preview.js +37 -27
- package/output/preview.js.map +1 -1
- package/output/{render-Di5B6Zc0.cjs → render-FICIzeXz.cjs} +2 -2
- package/output/{render-Di5B6Zc0.cjs.map → render-FICIzeXz.cjs.map} +1 -1
- package/output/{render-DKj24Jqw.js → render-XQiw_48i.js} +2 -2
- package/output/{render-DKj24Jqw.js.map → render-XQiw_48i.js.map} +1 -1
- package/output/renderer.css +1310 -318
- package/output/server.cjs +2 -2
- package/output/server.js +2 -2
- package/output/theme/ThemeEditor.d.ts +8 -4
- package/output/theme/variables.d.ts +8 -4
- package/package.json +1 -1
- package/output/ClarifyShell-1LuBliwt.js.map +0 -1
- package/output/ClarifyShell-C6li72Ce.cjs.map +0 -1
- package/output/OpenApiOperation-B52IWlKb.cjs.map +0 -1
- package/output/OpenApiOperation-DgrqzeiS.js.map +0 -1
- package/output/PageActions-BjB6PYmL.cjs.map +0 -1
- package/output/PageActions-D7K9LDGf.js.map +0 -1
- package/output/i18n-DnqZHFT7.js.map +0 -1
- package/output/i18n-b4iTLeia.cjs.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { a as useConfig, s as useLocale, t as useBuiltInText } from "./i18n-
|
|
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-
|
|
1
|
+
import { a as useConfig, s as useLocale, t as useBuiltInText } from "./i18n-BPrC45nD.js";
|
|
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-bugd7GZh.js";
|
|
3
3
|
import { t as markdownRemarkPlugins } from "./remark-C9iRQM0R.js";
|
|
4
4
|
import clsx from "clsx";
|
|
5
|
-
import { Children, Suspense, createContext, createElement, forwardRef, isValidElement, lazy, useContext, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
5
|
+
import { Children, Suspense, cloneElement, createContext, createElement, forwardRef, isValidElement, lazy, useContext, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
6
6
|
import { Link } from "react-router-dom";
|
|
7
|
-
import { Listbox, ListboxButton, ListboxOption, ListboxOptions, Tab, TabGroup, TabList, TabPanel, TabPanels, Transition } from "@headlessui/react";
|
|
8
|
-
import { AlertTriangle, ArrowRight, Check, CheckCircle2, CheckIcon, ChevronDown, ChevronDownIcon, ChevronRight, ChevronsUpDownIcon, CircleCheck, Clipboard, ClipboardIcon, CodeIcon, CopyIcon, Info, Lightbulb, LinkIcon,
|
|
7
|
+
import { Dialog, DialogBackdrop, DialogPanel, DialogTitle, Listbox, ListboxButton, ListboxOption, ListboxOptions, Tab, TabGroup, TabList, TabPanel, TabPanels, Transition } from "@headlessui/react";
|
|
8
|
+
import { AlertTriangle, ArrowRight, ArrowUpRight, Check, CheckCircle2, CheckIcon, ChevronDown, ChevronDownIcon, ChevronRight, ChevronsUpDownIcon, CircleAlertIcon, CircleCheck, Clipboard, ClipboardIcon, CodeIcon, CopyIcon, DownloadIcon, EraserIcon, File, FileX2Icon, Folder, FolderOpen, Info, InfoIcon, Lightbulb, LinkIcon, LoaderCircleIcon, Maximize2, PackageIcon, RotateCcwIcon, SearchIcon, SendIcon, ServerIcon, X, XCircle, XIcon } from "lucide-react";
|
|
9
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";
|
|
@@ -26,6 +26,32 @@ var __exportAll = (all, no_symbols) => {
|
|
|
26
26
|
return target;
|
|
27
27
|
};
|
|
28
28
|
//#endregion
|
|
29
|
+
//#region source/components/AccordionGroup.tsx
|
|
30
|
+
function AccordionGroup(arg0) {
|
|
31
|
+
const { children, multiple = false, className, ...props } = arg0;
|
|
32
|
+
const childArray = Children.toArray(children);
|
|
33
|
+
const [openIndex, setOpenIndex] = useState(() => {
|
|
34
|
+
const defaultIndex = childArray.findIndex((child) => isValidElement(child) && child.props.defaultOpen);
|
|
35
|
+
return defaultIndex === -1 ? null : defaultIndex;
|
|
36
|
+
});
|
|
37
|
+
const items = childArray.map((child, index) => {
|
|
38
|
+
if (!isValidElement(child)) return child;
|
|
39
|
+
if (multiple) return child;
|
|
40
|
+
return cloneElement(child, {
|
|
41
|
+
open: openIndex === index,
|
|
42
|
+
onOpenChange: (open) => {
|
|
43
|
+
child.props.onOpenChange?.(open);
|
|
44
|
+
setOpenIndex(open ? index : null);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
return /* @__PURE__ */ jsx("div", {
|
|
49
|
+
className: clsx("clarify-accordion-group my-6 divide-y divide-(--clarify-theme-tokens-colors-border) overflow-hidden rounded-(--clarify-theme-tokens-radius-lg) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) [&_.clarify-collapse]:my-0 [&_.clarify-collapse]:rounded-none [&_.clarify-collapse]:border-0", className),
|
|
50
|
+
...props,
|
|
51
|
+
children: items
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
29
55
|
//#region source/components/LocalizedLink.tsx
|
|
30
56
|
function useLocalizedHref(href) {
|
|
31
57
|
return localizeHref(href, useConfig(), useLocale());
|
|
@@ -45,15 +71,15 @@ function LocalizedLink(arg0) {
|
|
|
45
71
|
//#endregion
|
|
46
72
|
//#region source/components/Button.tsx
|
|
47
73
|
var buttonVariantStyles = {
|
|
48
|
-
primary: "
|
|
49
|
-
secondary: "
|
|
50
|
-
filled: "
|
|
51
|
-
outline: "
|
|
74
|
+
primary: "bg-(--clarify-theme-tokens-colors-foreground) px-4 text-(--clarify-theme-tokens-colors-background) shadow-sm hover:-translate-y-px hover:shadow-md active:translate-y-0 active:shadow-sm dark:bg-(--clarify-theme-tokens-colors-primary) dark:text-zinc-950",
|
|
75
|
+
secondary: "bg-(--clarify-theme-tokens-colors-code-background) px-4 text-(--clarify-ui-text-soft) ring-1 ring-inset ring-(--clarify-theme-tokens-colors-border) hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-theme-tokens-colors-foreground)",
|
|
76
|
+
filled: "bg-(--clarify-theme-tokens-colors-primary) px-4 text-white shadow-sm hover:-translate-y-px hover:shadow-md active:translate-y-0 dark:text-zinc-950",
|
|
77
|
+
outline: "px-4 text-(--clarify-ui-text-soft) ring-1 ring-inset ring-(--clarify-theme-tokens-colors-border) hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-theme-tokens-colors-foreground)",
|
|
52
78
|
text: "text-(--clarify-theme-tokens-colors-primary) hover:opacity-80 dark:text-(--clarify-theme-tokens-colors-primary) dark:hover:opacity-80"
|
|
53
79
|
};
|
|
54
80
|
function Button(arg0) {
|
|
55
81
|
const { variant = "primary", className, children, arrow, ...props } = arg0;
|
|
56
|
-
const classes = clsx("clarify-button not-prose inline-flex w-fit max-w-full items-center justify-center gap-1 overflow-hidden align-middle text-sm
|
|
82
|
+
const classes = clsx("clarify-button not-prose inline-flex w-fit max-w-full items-center justify-center gap-1.5 overflow-hidden align-middle text-sm font-semibold whitespace-nowrap no-underline transition duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary) focus-visible:ring-offset-2 focus-visible:ring-offset-(--clarify-theme-tokens-colors-background)", variant === "text" ? "h-auto rounded-sm" : "h-9 rounded-(--clarify-theme-tokens-radius-lg)", buttonVariantStyles[variant], className);
|
|
57
83
|
const arrowIcon = /* @__PURE__ */ jsx(ArrowRight, {
|
|
58
84
|
"aria-hidden": "true",
|
|
59
85
|
className: clsx("h-4 w-4 shrink-0", variant === "text" && "relative top-px", arrow === "left" && "-ml-0.5 rotate-180", arrow === "right" && "-mr-0.5")
|
|
@@ -81,37 +107,43 @@ function Button(arg0) {
|
|
|
81
107
|
//#region source/components/Callout.tsx
|
|
82
108
|
var calloutStyles = {
|
|
83
109
|
info: {
|
|
84
|
-
container: "border-sky-500/20 bg-sky-50/
|
|
110
|
+
container: "border-sky-500/20 bg-sky-50/30 dark:border-sky-400/20 dark:bg-sky-400/5",
|
|
111
|
+
iconContainer: "bg-sky-100 ring-sky-500/15 dark:bg-sky-400/10 dark:ring-sky-400/20",
|
|
85
112
|
icon: "text-sky-600 dark:text-sky-400",
|
|
86
113
|
title: "text-sky-900 dark:text-sky-100",
|
|
87
114
|
Icon: Info
|
|
88
115
|
},
|
|
89
116
|
note: {
|
|
90
|
-
container: "border-zinc-500/20 bg-zinc-50
|
|
117
|
+
container: "border-zinc-500/20 bg-zinc-50/50 dark:border-white/10 dark:bg-white/5",
|
|
118
|
+
iconContainer: "bg-zinc-200/70 ring-zinc-500/15 dark:bg-white/10 dark:ring-white/10",
|
|
91
119
|
icon: "text-zinc-500 dark:text-zinc-400",
|
|
92
120
|
title: "text-zinc-900 dark:text-white",
|
|
93
121
|
Icon: Info
|
|
94
122
|
},
|
|
95
123
|
tip: {
|
|
96
|
-
container: "border-emerald-500/20 bg-emerald-50/
|
|
124
|
+
container: "border-emerald-500/20 bg-emerald-50/30 dark:border-emerald-400/20 dark:bg-emerald-400/5",
|
|
125
|
+
iconContainer: "bg-emerald-100 ring-emerald-500/15 dark:bg-emerald-400/10 dark:ring-emerald-400/20",
|
|
97
126
|
icon: "text-emerald-600 dark:text-emerald-400",
|
|
98
127
|
title: "text-emerald-900 dark:text-emerald-100",
|
|
99
128
|
Icon: Lightbulb
|
|
100
129
|
},
|
|
101
130
|
warning: {
|
|
102
|
-
container: "border-amber-500/20 bg-amber-50/
|
|
131
|
+
container: "border-amber-500/20 bg-amber-50/40 dark:border-amber-400/20 dark:bg-amber-400/5",
|
|
132
|
+
iconContainer: "bg-amber-100 ring-amber-500/15 dark:bg-amber-400/10 dark:ring-amber-400/20",
|
|
103
133
|
icon: "text-amber-600 dark:text-amber-400",
|
|
104
134
|
title: "text-amber-900 dark:text-amber-100",
|
|
105
135
|
Icon: AlertTriangle
|
|
106
136
|
},
|
|
107
137
|
danger: {
|
|
108
|
-
container: "border-rose-500/20 bg-rose-50/
|
|
138
|
+
container: "border-rose-500/20 bg-rose-50/40 dark:border-rose-400/20 dark:bg-rose-400/5",
|
|
139
|
+
iconContainer: "bg-rose-100 ring-rose-500/15 dark:bg-rose-400/10 dark:ring-rose-400/20",
|
|
109
140
|
icon: "text-rose-600 dark:text-rose-400",
|
|
110
141
|
title: "text-rose-900 dark:text-rose-100",
|
|
111
142
|
Icon: XCircle
|
|
112
143
|
},
|
|
113
144
|
success: {
|
|
114
|
-
container: "border-emerald-500/20 bg-emerald-50/
|
|
145
|
+
container: "border-emerald-500/20 bg-emerald-50/30 dark:border-emerald-400/20 dark:bg-emerald-400/5",
|
|
146
|
+
iconContainer: "bg-emerald-100 ring-emerald-500/15 dark:bg-emerald-400/10 dark:ring-emerald-400/20",
|
|
115
147
|
icon: "text-emerald-600 dark:text-emerald-400",
|
|
116
148
|
title: "text-emerald-900 dark:text-emerald-100",
|
|
117
149
|
Icon: CheckCircle2
|
|
@@ -132,15 +164,18 @@ function Callout(arg0) {
|
|
|
132
164
|
const Icon = style.Icon;
|
|
133
165
|
const resolvedTitle = title === void 0 ? t(defaultTitleKeys[type]) : title;
|
|
134
166
|
return /* @__PURE__ */ jsxs("div", {
|
|
135
|
-
className: clsx("clarify-callout my-6 flex gap-3 rounded-(--clarify-theme-tokens-radius-
|
|
167
|
+
className: clsx("clarify-callout my-6 flex gap-3.5 rounded-(--clarify-theme-tokens-radius-lg) border p-4 text-sm/6 text-(--clarify-ui-text-soft)", style.container, className),
|
|
136
168
|
...props,
|
|
137
|
-
children: [icon ? /* @__PURE__ */ jsx(
|
|
138
|
-
className: clsx("
|
|
139
|
-
|
|
169
|
+
children: [icon ? /* @__PURE__ */ jsx("span", {
|
|
170
|
+
className: clsx("flex size-7 flex-none items-center justify-center rounded-(--clarify-theme-tokens-radius-md) ring-1 ring-inset", style.iconContainer),
|
|
171
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
172
|
+
className: clsx("size-4", style.icon),
|
|
173
|
+
"aria-hidden": "true"
|
|
174
|
+
})
|
|
140
175
|
}) : null, /* @__PURE__ */ jsxs("div", {
|
|
141
176
|
className: "min-w-0 flex-1 *:first:mt-0 *:last:mb-0",
|
|
142
177
|
children: [resolvedTitle ? /* @__PURE__ */ jsx("p", {
|
|
143
|
-
className: clsx("mb-1 font-semibold", style.title),
|
|
178
|
+
className: clsx("mb-1.5 font-semibold", style.title),
|
|
144
179
|
children: resolvedTitle
|
|
145
180
|
}) : null, /* @__PURE__ */ jsx("div", {
|
|
146
181
|
className: "*:first:mt-0 *:last:mb-0",
|
|
@@ -159,9 +194,9 @@ function CardIcon(arg0) {
|
|
|
159
194
|
const Icon = lucideIconRegistry[iconName];
|
|
160
195
|
if (!Icon) return null;
|
|
161
196
|
return /* @__PURE__ */ jsx("span", {
|
|
162
|
-
className: "flex size-
|
|
197
|
+
className: "flex size-8 flex-none items-center justify-center rounded-(--clarify-theme-tokens-radius-md) bg-(--clarify-ui-accent-background) text-(--clarify-ui-accent-text) ring-1 ring-inset ring-(--clarify-ui-accent-border) transition-colors group-hover:bg-(--clarify-theme-tokens-colors-primary) group-hover:text-white dark:group-hover:text-zinc-950",
|
|
163
198
|
children: /* @__PURE__ */ jsx(Icon, {
|
|
164
|
-
className: "size-
|
|
199
|
+
className: "size-4",
|
|
165
200
|
"aria-hidden": "true"
|
|
166
201
|
})
|
|
167
202
|
});
|
|
@@ -175,7 +210,7 @@ var cardGroupColumnStyles = {
|
|
|
175
210
|
function CardGroup(arg0) {
|
|
176
211
|
const { children, cols = 2, className } = arg0;
|
|
177
212
|
return /* @__PURE__ */ jsx("div", {
|
|
178
|
-
className: clsx("not-prose my-
|
|
213
|
+
className: clsx("not-prose my-8 grid gap-3", cardGroupColumnStyles[cols], className),
|
|
179
214
|
children
|
|
180
215
|
});
|
|
181
216
|
}
|
|
@@ -185,11 +220,17 @@ function Card(arg0) {
|
|
|
185
220
|
className: "flex items-start gap-4",
|
|
186
221
|
children: [/* @__PURE__ */ jsx(CardIcon, { name: icon }), /* @__PURE__ */ jsxs("div", {
|
|
187
222
|
className: "min-w-0 flex-1",
|
|
188
|
-
children: [/* @__PURE__ */
|
|
189
|
-
className: "
|
|
190
|
-
children:
|
|
223
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
224
|
+
className: "flex items-start justify-between gap-3",
|
|
225
|
+
children: [/* @__PURE__ */ jsx("h3", {
|
|
226
|
+
className: "m-0 text-sm/6 font-semibold text-(--clarify-theme-tokens-colors-foreground)",
|
|
227
|
+
children: title
|
|
228
|
+
}), href ? /* @__PURE__ */ jsx(ArrowUpRight, {
|
|
229
|
+
className: "mt-1 size-3.5 shrink-0 text-(--clarify-ui-text-faint) transition group-hover:-translate-y-0.5 group-hover:translate-x-0.5 group-hover:text-(--clarify-ui-accent-text)",
|
|
230
|
+
"aria-hidden": "true"
|
|
231
|
+
}) : null]
|
|
191
232
|
}), children ? /* @__PURE__ */ jsx("div", {
|
|
192
|
-
className: "mt-
|
|
233
|
+
className: "mt-1.5 text-sm/6 text-(--clarify-ui-text-soft) *:m-0",
|
|
193
234
|
children
|
|
194
235
|
}) : null]
|
|
195
236
|
})]
|
|
@@ -197,7 +238,7 @@ function Card(arg0) {
|
|
|
197
238
|
className: "absolute inset-0 rounded-(--clarify-theme-tokens-radius-xl)",
|
|
198
239
|
"aria-hidden": "true"
|
|
199
240
|
}) : null] });
|
|
200
|
-
const classes = clsx("group relative block rounded-(--clarify-theme-tokens-radius-
|
|
241
|
+
const classes = clsx("group relative block rounded-(--clarify-theme-tokens-radius-lg) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) p-4 transition duration-200", href && "hover:-translate-y-0.5 hover:border-(--clarify-ui-accent-border) hover:shadow-md hover:shadow-zinc-900/5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary) focus-visible:ring-offset-2 dark:hover:shadow-none", className);
|
|
201
242
|
if (!href) return /* @__PURE__ */ jsx("div", {
|
|
202
243
|
className: classes,
|
|
203
244
|
children: content
|
|
@@ -211,7 +252,7 @@ function Card(arg0) {
|
|
|
211
252
|
}
|
|
212
253
|
//#endregion
|
|
213
254
|
//#region source/components/Mermaid.tsx
|
|
214
|
-
var MermaidViewer = lazy(() => import("./MermaidViewer-
|
|
255
|
+
var MermaidViewer = lazy(() => import("./MermaidViewer-CkIxyqtf.js"));
|
|
215
256
|
var mermaidModulePromise;
|
|
216
257
|
async function loadMermaid() {
|
|
217
258
|
mermaidModulePromise = mermaidModulePromise ?? import("mermaid").then((module) => module.default);
|
|
@@ -337,6 +378,12 @@ function getNodeText(node) {
|
|
|
337
378
|
if (isValidElement(node)) return getNodeText(node.props.children);
|
|
338
379
|
return "";
|
|
339
380
|
}
|
|
381
|
+
function getCodeTitle(node) {
|
|
382
|
+
if (!isValidElement(node)) return void 0;
|
|
383
|
+
const { title, children } = node.props;
|
|
384
|
+
if (title) return title;
|
|
385
|
+
return Children.toArray(children).map(getCodeTitle).find(Boolean);
|
|
386
|
+
}
|
|
340
387
|
function getCodeLanguage(node) {
|
|
341
388
|
if (!isValidElement(node)) return void 0;
|
|
342
389
|
const { className, language, children } = node.props;
|
|
@@ -345,7 +392,14 @@ function getCodeLanguage(node) {
|
|
|
345
392
|
if (languageClass) return languageClass.slice(9);
|
|
346
393
|
return Children.toArray(children).map(getCodeLanguage).find(Boolean);
|
|
347
394
|
}
|
|
348
|
-
function
|
|
395
|
+
function getCodePanelTitle(node, fallbackTitle) {
|
|
396
|
+
return getPanelTitle({
|
|
397
|
+
title: getCodeTitle(node),
|
|
398
|
+
language: getCodeLanguage(node),
|
|
399
|
+
fallbackTitle
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
function CopyButton$1(arg0) {
|
|
349
403
|
const { code } = arg0;
|
|
350
404
|
const t = useBuiltInText();
|
|
351
405
|
const [copyCount, setCopyCount] = useState(0);
|
|
@@ -406,7 +460,7 @@ function CodePanel(arg0) {
|
|
|
406
460
|
children: [/* @__PURE__ */ jsx("pre", {
|
|
407
461
|
className: "clarify-code-pre overflow-x-auto p-4 text-xs text-(--clarify-code-text)",
|
|
408
462
|
children
|
|
409
|
-
}), /* @__PURE__ */ jsx(CopyButton, { code: copyText })]
|
|
463
|
+
}), /* @__PURE__ */ jsx(CopyButton$1, { code: copyText })]
|
|
410
464
|
})]
|
|
411
465
|
});
|
|
412
466
|
}
|
|
@@ -425,10 +479,7 @@ function CodeGroupHeader(arg0) {
|
|
|
425
479
|
className: "clarify-code-tabs -mr-2 -mb-px flex gap-0 text-xs font-medium",
|
|
426
480
|
children: Children.map(children, (child, childIndex) => /* @__PURE__ */ jsxs(Tab, {
|
|
427
481
|
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: [
|
|
429
|
-
...isValidElement(child) ? child.props : {},
|
|
430
|
-
fallbackTitle: t("actions.code")
|
|
431
|
-
}), childIndex === selectedIndex ? /* @__PURE__ */ jsx(motion.span, {
|
|
482
|
+
children: [getCodePanelTitle(child, t("actions.code")), childIndex === selectedIndex ? /* @__PURE__ */ jsx(motion.span, {
|
|
432
483
|
layoutId: indicatorLayoutId,
|
|
433
484
|
className: "absolute inset-x-2 bottom-0 h-0.5 rounded-full bg-(--clarify-code-accent-text)",
|
|
434
485
|
transition: {
|
|
@@ -502,10 +553,7 @@ var CodeGroupContext = createContext(false);
|
|
|
502
553
|
function CodeGroup(arg0) {
|
|
503
554
|
const { children, title, ...props } = arg0;
|
|
504
555
|
const t = useBuiltInText();
|
|
505
|
-
const tabGroupProps = useTabGroupProps(Children.map(children, (child) =>
|
|
506
|
-
...isValidElement(child) ? child.props : {},
|
|
507
|
-
fallbackTitle: t("actions.code")
|
|
508
|
-
})) ?? []);
|
|
556
|
+
const tabGroupProps = useTabGroupProps(Children.map(children, (child) => getCodePanelTitle(child, t("actions.code"))) ?? []);
|
|
509
557
|
const hasTabs = Children.count(children) > 1;
|
|
510
558
|
const containerClassName = "clarify-code-group my-6 overflow-hidden rounded-2xl bg-(--clarify-code-background) shadow-md ring-1 ring-(--clarify-code-border)";
|
|
511
559
|
const header = /* @__PURE__ */ jsx(CodeGroupHeader, {
|
|
@@ -561,8 +609,9 @@ function Pre(arg0) {
|
|
|
561
609
|
//#endregion
|
|
562
610
|
//#region source/components/Collapse.tsx
|
|
563
611
|
function Collapse(arg0) {
|
|
564
|
-
const { children, title, summary, defaultOpen = false, className, ...props } = arg0;
|
|
565
|
-
const [
|
|
612
|
+
const { children, title, summary, defaultOpen = false, open: controlledOpen, onOpenChange, className, ...props } = arg0;
|
|
613
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
|
|
614
|
+
const open = controlledOpen ?? uncontrolledOpen;
|
|
566
615
|
const contentRef = useRef(null);
|
|
567
616
|
const [maxHeight, setMaxHeight] = useState("0px");
|
|
568
617
|
const summaryLabel = title ?? summary ?? "Details";
|
|
@@ -572,16 +621,20 @@ function Collapse(arg0) {
|
|
|
572
621
|
setMaxHeight(open ? `${contentRef.current.scrollHeight}px` : "0px");
|
|
573
622
|
}, [open, children]);
|
|
574
623
|
return /* @__PURE__ */ jsxs("div", {
|
|
575
|
-
className: clsx("clarify-collapse my-6 overflow-hidden rounded-(--clarify-theme-tokens-radius-
|
|
624
|
+
className: clsx("clarify-collapse my-6 overflow-hidden rounded-(--clarify-theme-tokens-radius-lg) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) transition-colors", open && "border-(--clarify-ui-accent-border)", className),
|
|
576
625
|
...props,
|
|
577
626
|
children: [/* @__PURE__ */ jsxs("button", {
|
|
578
627
|
type: "button",
|
|
579
|
-
className: "flex w-full cursor-pointer items-center justify-between gap-3 px-4 py-
|
|
628
|
+
className: "flex min-h-11 w-full cursor-pointer items-center justify-between gap-3 px-4 py-2.5 text-left text-sm font-semibold text-(--clarify-theme-tokens-colors-foreground) transition hover:bg-(--clarify-ui-hover-background) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
|
|
580
629
|
"aria-expanded": open,
|
|
581
630
|
"aria-controls": contentId,
|
|
582
|
-
onClick: () =>
|
|
631
|
+
onClick: () => {
|
|
632
|
+
const nextOpen = !open;
|
|
633
|
+
if (controlledOpen === void 0) setUncontrolledOpen(nextOpen);
|
|
634
|
+
onOpenChange?.(nextOpen);
|
|
635
|
+
},
|
|
583
636
|
children: [/* @__PURE__ */ jsx("span", { children: summaryLabel }), /* @__PURE__ */ jsx(ChevronDown, {
|
|
584
|
-
className: clsx("
|
|
637
|
+
className: clsx("size-4 rounded-full text-(--clarify-ui-text-faint) transition duration-200", open && "rotate-180"),
|
|
585
638
|
"aria-hidden": "true"
|
|
586
639
|
})]
|
|
587
640
|
}), /* @__PURE__ */ jsx("div", {
|
|
@@ -593,7 +646,7 @@ function Collapse(arg0) {
|
|
|
593
646
|
},
|
|
594
647
|
children: /* @__PURE__ */ jsx("div", {
|
|
595
648
|
ref: contentRef,
|
|
596
|
-
className: clsx("px-4 py-4 text-sm/6 text-(--clarify-
|
|
649
|
+
className: clsx("px-4 py-4 text-sm/6 text-(--clarify-ui-text-soft) transition-opacity duration-200 ease-out *:first:mt-0 *:last:mb-0", open ? "opacity-100 translate-y-0" : "opacity-0 -translate-y-1"),
|
|
597
650
|
children
|
|
598
651
|
})
|
|
599
652
|
})]
|
|
@@ -669,6 +722,55 @@ function Feedback() {
|
|
|
669
722
|
});
|
|
670
723
|
}
|
|
671
724
|
//#endregion
|
|
725
|
+
//#region source/components/FileTree.tsx
|
|
726
|
+
function FileTree(arg0) {
|
|
727
|
+
const { children, className, ...props } = arg0;
|
|
728
|
+
return /* @__PURE__ */ jsx("div", {
|
|
729
|
+
className: clsx("clarify-file-tree not-prose my-6 overflow-x-auto rounded-(--clarify-theme-tokens-radius-lg) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) px-4 py-3 font-mono text-[13px]/6 text-(--clarify-ui-text-soft)", className),
|
|
730
|
+
...props,
|
|
731
|
+
children: /* @__PURE__ */ jsx("ul", {
|
|
732
|
+
role: "tree",
|
|
733
|
+
className: "m-0 min-w-max list-none p-0",
|
|
734
|
+
children
|
|
735
|
+
})
|
|
736
|
+
});
|
|
737
|
+
}
|
|
738
|
+
function FileTreeItem(arg0) {
|
|
739
|
+
const { name, description, type, children, className, ...props } = arg0;
|
|
740
|
+
const isFolder = type === "folder" || children != null;
|
|
741
|
+
const FolderIcon = children ? FolderOpen : Folder;
|
|
742
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
743
|
+
role: "treeitem",
|
|
744
|
+
"aria-expanded": isFolder ? children != null : void 0,
|
|
745
|
+
className: clsx("clarify-file-tree-item m-0 p-0", className),
|
|
746
|
+
...props,
|
|
747
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
748
|
+
className: "flex min-h-6 items-center gap-2 whitespace-nowrap",
|
|
749
|
+
children: [
|
|
750
|
+
isFolder ? /* @__PURE__ */ jsx(FolderIcon, {
|
|
751
|
+
className: "size-4 flex-none text-(--clarify-ui-accent-text)",
|
|
752
|
+
"aria-hidden": "true"
|
|
753
|
+
}) : /* @__PURE__ */ jsx(File, {
|
|
754
|
+
className: "size-4 flex-none text-(--clarify-ui-text-faint)",
|
|
755
|
+
"aria-hidden": "true"
|
|
756
|
+
}),
|
|
757
|
+
/* @__PURE__ */ jsx("span", {
|
|
758
|
+
className: "font-medium text-(--clarify-theme-tokens-colors-foreground)",
|
|
759
|
+
children: name
|
|
760
|
+
}),
|
|
761
|
+
description ? /* @__PURE__ */ jsx("span", {
|
|
762
|
+
className: "font-sans text-xs text-(--clarify-ui-text-faint)",
|
|
763
|
+
children: description
|
|
764
|
+
}) : null
|
|
765
|
+
]
|
|
766
|
+
}), children ? /* @__PURE__ */ jsx("ul", {
|
|
767
|
+
role: "group",
|
|
768
|
+
className: "m-0 ml-2.5 list-none border-l border-(--clarify-theme-tokens-colors-border) pl-4",
|
|
769
|
+
children
|
|
770
|
+
}) : null]
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
//#endregion
|
|
672
774
|
//#region source/components/Tag.tsx
|
|
673
775
|
var tagVariantStyles = {
|
|
674
776
|
small: "",
|
|
@@ -875,10 +977,50 @@ function Prose(arg0) {
|
|
|
875
977
|
});
|
|
876
978
|
}
|
|
877
979
|
//#endregion
|
|
980
|
+
//#region source/components/Steps.tsx
|
|
981
|
+
function Steps(arg0) {
|
|
982
|
+
const { children, className, ...props } = arg0;
|
|
983
|
+
return /* @__PURE__ */ jsx("ol", {
|
|
984
|
+
className: clsx("clarify-steps my-8 ml-3 list-none border-l-2 border-(--clarify-theme-tokens-colors-border) p-0", className),
|
|
985
|
+
...props,
|
|
986
|
+
children
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
function Step(arg0) {
|
|
990
|
+
const { children, title, className, ...props } = arg0;
|
|
991
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
992
|
+
className: clsx("clarify-step relative m-0 pb-10 pl-9 last:pb-0", className),
|
|
993
|
+
...props,
|
|
994
|
+
children: [
|
|
995
|
+
/* @__PURE__ */ jsx("span", {
|
|
996
|
+
className: "absolute top-0 -left-3.5 flex size-7 items-center justify-center rounded-full bg-(--clarify-theme-tokens-colors-primary) text-xs font-semibold text-white shadow-[0_0_0_4px_var(--clarify-theme-tokens-colors-background)] before:content-[counter(list-item)] dark:text-zinc-950",
|
|
997
|
+
"aria-hidden": "true"
|
|
998
|
+
}),
|
|
999
|
+
title ? /* @__PURE__ */ jsx("h3", {
|
|
1000
|
+
className: "m-0 pt-0.5 text-base font-semibold text-(--clarify-theme-tokens-colors-foreground)",
|
|
1001
|
+
children: title
|
|
1002
|
+
}) : null,
|
|
1003
|
+
/* @__PURE__ */ jsx("div", {
|
|
1004
|
+
className: clsx("text-sm/6 text-(--clarify-ui-text-soft) *:last:mb-0", title && "mt-2.5", !title && "*:first:mt-0"),
|
|
1005
|
+
children
|
|
1006
|
+
})
|
|
1007
|
+
]
|
|
1008
|
+
});
|
|
1009
|
+
}
|
|
1010
|
+
//#endregion
|
|
878
1011
|
//#region source/components/Tabs.tsx
|
|
1012
|
+
function TabItem(_props) {
|
|
1013
|
+
return null;
|
|
1014
|
+
}
|
|
879
1015
|
function Tabs(arg0) {
|
|
880
|
-
const { items, selectedIndex, onChange, className, listClassName, panelsClassName } = arg0;
|
|
881
|
-
const
|
|
1016
|
+
const { items, children, defaultValue, selectedIndex, onChange, className, listClassName, panelsClassName } = arg0;
|
|
1017
|
+
const childItems = Children.toArray(children).filter((child) => isValidElement(child) && child.type === TabItem).map((child, index) => ({
|
|
1018
|
+
id: child.props.value ?? `tab-${index}`,
|
|
1019
|
+
label: child.props.title,
|
|
1020
|
+
panel: child.props.children
|
|
1021
|
+
}));
|
|
1022
|
+
const resolvedItems = items ?? childItems;
|
|
1023
|
+
const [internalIndex, setInternalIndex] = useState(defaultValue ? Math.max(0, resolvedItems.findIndex((item) => item.id === defaultValue)) : 0);
|
|
882
1024
|
const resolvedIndex = typeof selectedIndex === "number" ? selectedIndex : internalIndex;
|
|
883
1025
|
const indicatorLayoutId = useId();
|
|
884
1026
|
const handleChange = (index) => {
|
|
@@ -888,32 +1030,93 @@ function Tabs(arg0) {
|
|
|
888
1030
|
return /* @__PURE__ */ jsxs(TabGroup, {
|
|
889
1031
|
selectedIndex: resolvedIndex,
|
|
890
1032
|
onChange: handleChange,
|
|
891
|
-
className,
|
|
1033
|
+
className: clsx("clarify-tabs my-6", className),
|
|
892
1034
|
children: [/* @__PURE__ */ jsx(TabList, {
|
|
893
|
-
className: clsx("
|
|
894
|
-
children:
|
|
895
|
-
className: ({ selected }) => clsx("clarify-content-tab clarify-ui-tab relative inline-flex h-
|
|
1035
|
+
className: clsx("flex max-w-full items-stretch gap-1 overflow-x-auto border-b border-(--clarify-theme-tokens-colors-border)", listClassName),
|
|
1036
|
+
children: resolvedItems.map((item) => /* @__PURE__ */ jsx(Tab, {
|
|
1037
|
+
className: ({ selected }) => clsx("clarify-content-tab clarify-ui-tab relative my-1 inline-flex h-9 shrink-0 items-center rounded-(--clarify-theme-tokens-radius-md) px-2.5 transition focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-(--clarify-theme-tokens-colors-primary)", selected && "clarify-ui-tab-active"),
|
|
896
1038
|
children: ({ selected }) => /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", { children: item.label }), selected ? /* @__PURE__ */ jsx(motion.span, {
|
|
897
1039
|
layoutId: indicatorLayoutId,
|
|
898
|
-
className: "absolute inset-x-2 bottom-
|
|
1040
|
+
className: "absolute inset-x-2.5 -bottom-1 h-0.5 rounded-full bg-(--clarify-ui-tab-indicator)",
|
|
899
1041
|
transition: {
|
|
900
|
-
type: "
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
mass: .7
|
|
1042
|
+
type: "tween",
|
|
1043
|
+
duration: .16,
|
|
1044
|
+
ease: "easeOut"
|
|
904
1045
|
}
|
|
905
1046
|
}) : null] })
|
|
906
1047
|
}, item.id))
|
|
907
1048
|
}), /* @__PURE__ */ jsx(TabPanels, {
|
|
908
|
-
className: clsx("mt-
|
|
909
|
-
children:
|
|
910
|
-
className: "focus:outline-none",
|
|
1049
|
+
className: clsx("mt-5", panelsClassName),
|
|
1050
|
+
children: resolvedItems.map((item) => /* @__PURE__ */ jsx(TabPanel, {
|
|
1051
|
+
className: "focus:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
|
|
911
1052
|
children: item.panel
|
|
912
1053
|
}, item.id))
|
|
913
1054
|
})]
|
|
914
1055
|
});
|
|
915
1056
|
}
|
|
916
1057
|
//#endregion
|
|
1058
|
+
//#region source/components/Tooltip.tsx
|
|
1059
|
+
function Tooltip(arg0) {
|
|
1060
|
+
const { content, children, side = "top", className, triggerClassName, ...props } = arg0;
|
|
1061
|
+
const contentId = useId();
|
|
1062
|
+
const [open, setOpen] = useState(false);
|
|
1063
|
+
const triggerRef = useRef(null);
|
|
1064
|
+
const tooltipRef = useRef(null);
|
|
1065
|
+
const [position, setPosition] = useState();
|
|
1066
|
+
useEffect(() => {
|
|
1067
|
+
if (!open) return;
|
|
1068
|
+
function updatePosition() {
|
|
1069
|
+
const bounds = triggerRef.current?.getBoundingClientRect();
|
|
1070
|
+
if (!bounds) return;
|
|
1071
|
+
setPosition({
|
|
1072
|
+
left: bounds.left + bounds.width / 2,
|
|
1073
|
+
top: side === "top" ? bounds.top - 8 : bounds.bottom + 8
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1076
|
+
updatePosition();
|
|
1077
|
+
window.addEventListener("resize", updatePosition);
|
|
1078
|
+
window.addEventListener("scroll", updatePosition, true);
|
|
1079
|
+
return () => {
|
|
1080
|
+
window.removeEventListener("resize", updatePosition);
|
|
1081
|
+
window.removeEventListener("scroll", updatePosition, true);
|
|
1082
|
+
};
|
|
1083
|
+
}, [open, side]);
|
|
1084
|
+
useEffect(() => {
|
|
1085
|
+
const tooltip = tooltipRef.current;
|
|
1086
|
+
if (!tooltip || typeof tooltip.showPopover !== "function") return;
|
|
1087
|
+
if (open) tooltip.showPopover();
|
|
1088
|
+
else if (tooltip.matches(":popover-open")) tooltip.hidePopover();
|
|
1089
|
+
}, [open]);
|
|
1090
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
1091
|
+
className: clsx("clarify-tooltip group inline-flex align-baseline", className),
|
|
1092
|
+
onMouseEnter: () => setOpen(true),
|
|
1093
|
+
onMouseLeave: () => setOpen(false),
|
|
1094
|
+
...props,
|
|
1095
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
1096
|
+
type: "button",
|
|
1097
|
+
ref: triggerRef,
|
|
1098
|
+
"aria-describedby": contentId,
|
|
1099
|
+
"aria-expanded": open,
|
|
1100
|
+
className: clsx("cursor-help appearance-none rounded-sm border-0 border-b border-dotted border-current bg-transparent p-0 font-inherit text-inherit focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)", triggerClassName),
|
|
1101
|
+
onFocus: () => setOpen(true),
|
|
1102
|
+
onBlur: () => setOpen(false),
|
|
1103
|
+
onClick: () => setOpen(true),
|
|
1104
|
+
onKeyDown: (event) => {
|
|
1105
|
+
if (event.key === "Escape") setOpen(false);
|
|
1106
|
+
},
|
|
1107
|
+
children
|
|
1108
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
1109
|
+
ref: tooltipRef,
|
|
1110
|
+
id: contentId,
|
|
1111
|
+
role: "tooltip",
|
|
1112
|
+
popover: "manual",
|
|
1113
|
+
style: position,
|
|
1114
|
+
className: clsx("pointer-events-none fixed right-auto bottom-auto z-60 m-0 w-max max-w-64 -translate-x-1/2 rounded-md border-0 bg-(--clarify-theme-tokens-colors-foreground) px-2.5 py-1.5 text-center text-xs/5 font-normal text-(--clarify-theme-tokens-colors-background) shadow-lg transition duration-150", side === "top" && "-translate-y-full", open && position ? "visible opacity-100" : "invisible opacity-0"),
|
|
1115
|
+
children: content
|
|
1116
|
+
})]
|
|
1117
|
+
});
|
|
1118
|
+
}
|
|
1119
|
+
//#endregion
|
|
917
1120
|
//#region source/components/WebFrame.tsx
|
|
918
1121
|
function WebFrame(arg0) {
|
|
919
1122
|
const { src, title = "Embedded content", children, showWindow = true, className, iframeClassName, height = 420, style, ...props } = arg0;
|
|
@@ -936,53 +1139,122 @@ function WebFrame(arg0) {
|
|
|
936
1139
|
children
|
|
937
1140
|
});
|
|
938
1141
|
if (!showWindow) return /* @__PURE__ */ jsx("div", {
|
|
939
|
-
className: clsx("clarify-web-frame not-prose my-10 overflow-hidden rounded-(--clarify-theme-tokens-radius-
|
|
1142
|
+
className: clsx("clarify-web-frame not-prose my-10 overflow-hidden rounded-(--clarify-theme-tokens-radius-lg) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) shadow-lg shadow-zinc-900/5 dark:shadow-none", className),
|
|
940
1143
|
children: frame
|
|
941
1144
|
});
|
|
942
1145
|
return /* @__PURE__ */ jsxs("div", {
|
|
943
|
-
className: clsx("clarify-web-frame not-prose my-10 overflow-hidden rounded-(--clarify-theme-tokens-radius-
|
|
1146
|
+
className: clsx("clarify-web-frame not-prose my-10 overflow-hidden rounded-(--clarify-theme-tokens-radius-lg) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) shadow-lg shadow-zinc-900/5 dark:shadow-none", className),
|
|
944
1147
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
945
|
-
className: "
|
|
1148
|
+
className: "grid h-10 grid-cols-[1fr_minmax(0,2fr)_1fr] items-center gap-3 border-b border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-code-background) px-3",
|
|
946
1149
|
children: [
|
|
947
|
-
/* @__PURE__ */
|
|
948
|
-
className: "
|
|
949
|
-
"aria-hidden": "true"
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
/* @__PURE__ */ jsx("span", {
|
|
956
|
-
className: "size-3 rounded-full bg-green-400",
|
|
957
|
-
"aria-hidden": "true"
|
|
1150
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1151
|
+
className: "flex items-center gap-1.5",
|
|
1152
|
+
"aria-hidden": "true",
|
|
1153
|
+
children: [
|
|
1154
|
+
/* @__PURE__ */ jsx("span", { className: "size-2.5 rounded-full bg-red-400/80" }),
|
|
1155
|
+
/* @__PURE__ */ jsx("span", { className: "size-2.5 rounded-full bg-amber-400/80" }),
|
|
1156
|
+
/* @__PURE__ */ jsx("span", { className: "size-2.5 rounded-full bg-emerald-400/80" })
|
|
1157
|
+
]
|
|
958
1158
|
}),
|
|
959
|
-
/* @__PURE__ */ jsx("
|
|
960
|
-
className: "
|
|
1159
|
+
/* @__PURE__ */ jsx("div", {
|
|
1160
|
+
className: "truncate rounded-(--clarify-theme-tokens-radius-md) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) px-3 py-1 text-center text-xs text-(--clarify-ui-text-faint)",
|
|
961
1161
|
children: title
|
|
962
|
-
})
|
|
1162
|
+
}),
|
|
1163
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true" })
|
|
963
1164
|
]
|
|
964
1165
|
}), frame]
|
|
965
1166
|
});
|
|
966
1167
|
}
|
|
967
1168
|
//#endregion
|
|
1169
|
+
//#region source/components/Image.tsx
|
|
1170
|
+
function Image(arg0) {
|
|
1171
|
+
const { src, alt = "", caption, zoom = false, className, ...props } = arg0;
|
|
1172
|
+
const [open, setOpen] = useState(false);
|
|
1173
|
+
const image = /* @__PURE__ */ jsx("img", {
|
|
1174
|
+
...props,
|
|
1175
|
+
src,
|
|
1176
|
+
alt,
|
|
1177
|
+
className: clsx("block h-auto max-w-full object-contain", className)
|
|
1178
|
+
});
|
|
1179
|
+
return /* @__PURE__ */ jsxs("figure", {
|
|
1180
|
+
className: "clarify-figure not-prose mx-auto my-8 w-fit max-w-full",
|
|
1181
|
+
children: [
|
|
1182
|
+
/* @__PURE__ */ jsx("div", {
|
|
1183
|
+
className: "group relative w-fit max-w-full overflow-hidden rounded-(--clarify-theme-tokens-radius-lg) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-ui-subtle-background)",
|
|
1184
|
+
children: zoom ? /* @__PURE__ */ jsxs("button", {
|
|
1185
|
+
type: "button",
|
|
1186
|
+
className: "block max-w-full cursor-zoom-in focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
|
|
1187
|
+
"aria-label": `Enlarge image: ${alt}`,
|
|
1188
|
+
onClick: () => setOpen(true),
|
|
1189
|
+
children: [image, /* @__PURE__ */ jsx("span", {
|
|
1190
|
+
className: "absolute right-3 bottom-3 grid size-8 place-items-center rounded-md border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-background)/90 text-(--clarify-ui-text-soft) opacity-0 shadow-sm transition group-hover:opacity-100 group-focus-within:opacity-100",
|
|
1191
|
+
children: /* @__PURE__ */ jsx(Maximize2, {
|
|
1192
|
+
className: "size-4",
|
|
1193
|
+
"aria-hidden": "true"
|
|
1194
|
+
})
|
|
1195
|
+
})]
|
|
1196
|
+
}) : image
|
|
1197
|
+
}),
|
|
1198
|
+
caption ? /* @__PURE__ */ jsx("figcaption", {
|
|
1199
|
+
className: "mt-2 text-center text-xs/5 text-(--clarify-ui-text-faint)",
|
|
1200
|
+
children: caption
|
|
1201
|
+
}) : null,
|
|
1202
|
+
zoom ? /* @__PURE__ */ jsxs(Dialog, {
|
|
1203
|
+
open,
|
|
1204
|
+
onClose: setOpen,
|
|
1205
|
+
className: "relative z-50",
|
|
1206
|
+
children: [/* @__PURE__ */ jsx(DialogBackdrop, { className: "fixed inset-0 bg-black/75 backdrop-blur-sm" }), /* @__PURE__ */ jsx("div", {
|
|
1207
|
+
className: "fixed inset-0 flex items-center justify-center p-4 sm:p-8",
|
|
1208
|
+
children: /* @__PURE__ */ jsxs(DialogPanel, {
|
|
1209
|
+
className: "relative max-h-full max-w-full overflow-auto rounded-(--clarify-theme-tokens-radius-lg) bg-(--clarify-theme-tokens-colors-background) p-2 shadow-2xl",
|
|
1210
|
+
children: [/* @__PURE__ */ jsx("img", {
|
|
1211
|
+
src,
|
|
1212
|
+
alt,
|
|
1213
|
+
className: "max-h-[calc(100dvh-5rem)] max-w-[calc(100vw-5rem)] object-contain"
|
|
1214
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
1215
|
+
type: "button",
|
|
1216
|
+
className: "absolute top-4 right-4 grid size-9 place-items-center rounded-md border border-white/20 bg-black/65 text-white transition hover:bg-black/80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white",
|
|
1217
|
+
"aria-label": "Close image preview",
|
|
1218
|
+
onClick: () => setOpen(false),
|
|
1219
|
+
children: /* @__PURE__ */ jsx(X, {
|
|
1220
|
+
className: "size-4",
|
|
1221
|
+
"aria-hidden": "true"
|
|
1222
|
+
})
|
|
1223
|
+
})]
|
|
1224
|
+
})
|
|
1225
|
+
})]
|
|
1226
|
+
}) : null
|
|
1227
|
+
]
|
|
1228
|
+
});
|
|
1229
|
+
}
|
|
1230
|
+
//#endregion
|
|
968
1231
|
//#region source/mdx/primitives.tsx
|
|
969
1232
|
var primitives_exports = /* @__PURE__ */ __exportAll({
|
|
1233
|
+
AccordionGroup: () => AccordionGroup,
|
|
970
1234
|
Button: () => Button,
|
|
971
1235
|
Callout: () => Callout,
|
|
972
1236
|
Card: () => Card,
|
|
973
1237
|
CardGroup: () => CardGroup,
|
|
974
1238
|
CodeGroup: () => CodeGroup,
|
|
975
1239
|
Col: () => Col,
|
|
1240
|
+
FileTree: () => FileTree,
|
|
1241
|
+
FileTreeItem: () => FileTreeItem,
|
|
976
1242
|
Note: () => Note,
|
|
977
1243
|
Properties: () => Properties,
|
|
978
1244
|
Property: () => Property,
|
|
979
1245
|
Row: () => Row,
|
|
1246
|
+
Step: () => Step,
|
|
1247
|
+
Steps: () => Steps,
|
|
1248
|
+
Tab: () => TabItem,
|
|
1249
|
+
Tabs: () => Tabs,
|
|
1250
|
+
Tooltip: () => Tooltip,
|
|
980
1251
|
WebFrame: () => WebFrame,
|
|
981
1252
|
a: () => a,
|
|
982
1253
|
code: () => code,
|
|
983
1254
|
h1: () => h1,
|
|
984
1255
|
h2: () => h2,
|
|
985
1256
|
h3: () => h3,
|
|
1257
|
+
img: () => img,
|
|
986
1258
|
pre: () => pre,
|
|
987
1259
|
table: () => table,
|
|
988
1260
|
wrapper: () => wrapper
|
|
@@ -1027,6 +1299,7 @@ function h1(arg0) {
|
|
|
1027
1299
|
}
|
|
1028
1300
|
var code = Code;
|
|
1029
1301
|
var pre = Pre;
|
|
1302
|
+
var img = Image;
|
|
1030
1303
|
function h2(props) {
|
|
1031
1304
|
return createElement(Heading, {
|
|
1032
1305
|
level: 2,
|
|
@@ -1042,8 +1315,8 @@ function h3(props) {
|
|
|
1042
1315
|
function Note(arg0) {
|
|
1043
1316
|
const { children } = arg0;
|
|
1044
1317
|
return /* @__PURE__ */ jsxs("div", {
|
|
1045
|
-
className: "clarify-note my-6 flex gap-
|
|
1046
|
-
children: [/* @__PURE__ */ jsx(Info, { className: "mt-1
|
|
1318
|
+
className: "clarify-note my-6 flex gap-3 rounded-r-(--clarify-theme-tokens-radius-lg) border-l-2 border-(--clarify-theme-tokens-colors-primary) bg-(--clarify-ui-subtle-background) px-4 py-3 text-sm/6 text-(--clarify-ui-text-soft) [--tw-prose-links-hover:var(--clarify-ui-accent-text)] [--tw-prose-links:var(--clarify-theme-tokens-colors-foreground)]",
|
|
1319
|
+
children: [/* @__PURE__ */ jsx(Info, { className: "mt-1 size-4 flex-none stroke-(--clarify-ui-accent-text)" }), /* @__PURE__ */ jsx("div", {
|
|
1047
1320
|
className: "*:first:mt-0 *:last:mb-0",
|
|
1048
1321
|
children
|
|
1049
1322
|
})]
|
|
@@ -1417,6 +1690,23 @@ function listOpenApiOperations(spec) {
|
|
|
1417
1690
|
return [...listOperationsFromPathItems(paths, "path", spec), ...isRecord(webhooks) ? listOperationsFromPathItems(webhooks, "webhook", spec) : []];
|
|
1418
1691
|
}
|
|
1419
1692
|
//#endregion
|
|
1693
|
+
//#region source/openapi/components/EndpointMethodBadge.tsx
|
|
1694
|
+
var endpointMethodStyleVars = {
|
|
1695
|
+
GET: "bg-(--clarify-http-method-get-background) text-(--clarify-http-method-get-text)",
|
|
1696
|
+
POST: "bg-(--clarify-http-method-post-background) text-(--clarify-http-method-post-text)",
|
|
1697
|
+
PUT: "bg-(--clarify-http-method-put-background) text-(--clarify-http-method-put-text)",
|
|
1698
|
+
PATCH: "bg-(--clarify-http-method-patch-background) text-(--clarify-http-method-patch-text)",
|
|
1699
|
+
DELETE: "bg-(--clarify-http-method-delete-background) text-(--clarify-http-method-delete-text)",
|
|
1700
|
+
WEBHOOK: "bg-(--clarify-http-method-webhook-background) text-(--clarify-http-method-webhook-text)"
|
|
1701
|
+
};
|
|
1702
|
+
function EndpointMethodBadge(arg0) {
|
|
1703
|
+
const { method } = arg0;
|
|
1704
|
+
return /* @__PURE__ */ jsx("span", {
|
|
1705
|
+
className: clsx("rounded-(--clarify-theme-tokens-radius-md) px-2.5 py-0.5 text-xs/6 font-black tracking-wide", endpointMethodStyleVars[method] ?? "bg-(--clarify-http-method-default-background) text-(--clarify-http-method-default-text)"),
|
|
1706
|
+
children: method
|
|
1707
|
+
});
|
|
1708
|
+
}
|
|
1709
|
+
//#endregion
|
|
1420
1710
|
//#region source/components/HighlightedCode.tsx
|
|
1421
1711
|
var cssVariablesTheme = createCssVariablesTheme();
|
|
1422
1712
|
function HighlightedCode(arg0) {
|
|
@@ -1474,6 +1764,15 @@ var snippetControlCharacters = [
|
|
|
1474
1764
|
}
|
|
1475
1765
|
];
|
|
1476
1766
|
var snippetGenerator = snippetz();
|
|
1767
|
+
function getAuthPlaceholder(name) {
|
|
1768
|
+
return `YOUR_${name.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[^a-zA-Z0-9]+/g, "_").toUpperCase() || "CREDENTIAL"}`;
|
|
1769
|
+
}
|
|
1770
|
+
function redactAuth(auth = []) {
|
|
1771
|
+
return auth.map((input) => ({
|
|
1772
|
+
...input,
|
|
1773
|
+
value: getAuthPlaceholder(input.name)
|
|
1774
|
+
}));
|
|
1775
|
+
}
|
|
1477
1776
|
function protectSnippetControlCharacters(value) {
|
|
1478
1777
|
if (typeof value === "string") return snippetControlCharacters.reduce((result, item) => result.replaceAll(item.character, item.placeholder), value);
|
|
1479
1778
|
if (Array.isArray(value)) return value.map(protectSnippetControlCharacters);
|
|
@@ -1492,7 +1791,7 @@ function getDefaultServer(spec) {
|
|
|
1492
1791
|
function getDefaultWebhookServer() {
|
|
1493
1792
|
return { url: "https://webhook.example.com" };
|
|
1494
1793
|
}
|
|
1495
|
-
function expandServerUrl(server, serverVariables = {}) {
|
|
1794
|
+
function expandServerUrl$1(server, serverVariables = {}) {
|
|
1496
1795
|
return (server.url ?? "https://api.example.com").replace(/\{([^}]+)\}/g, (_, name) => {
|
|
1497
1796
|
const fallback = server.variables?.[name]?.default ?? name;
|
|
1498
1797
|
return serverVariables[name] ?? fallback;
|
|
@@ -1500,16 +1799,16 @@ function expandServerUrl(server, serverVariables = {}) {
|
|
|
1500
1799
|
}
|
|
1501
1800
|
function buildOperationUrl(input) {
|
|
1502
1801
|
const defaultServer = input.operationSource === "webhook" ? getDefaultWebhookServer() : getDefaultServer(input.spec);
|
|
1503
|
-
return joinPath(expandServerUrl(input.server ?? defaultServer, input.serverVariables), input.path);
|
|
1802
|
+
return joinPath(expandServerUrl$1(input.server ?? defaultServer, input.serverVariables), input.path);
|
|
1504
1803
|
}
|
|
1505
|
-
function getQueryString(parameters, auth) {
|
|
1804
|
+
function getQueryString(parameters, auth = []) {
|
|
1506
1805
|
const queryString = parameters.filter((parameter) => parameter.in === "query" && parameter.name).map((parameter) => ({
|
|
1507
1806
|
name: parameter.name,
|
|
1508
1807
|
value: encodeUrlPlaceholders(`{${parameter.name}}`)
|
|
1509
1808
|
}));
|
|
1510
|
-
if (
|
|
1511
|
-
name:
|
|
1512
|
-
value:
|
|
1809
|
+
for (const input of auth) if (input.scheme.type === "apiKey" && input.scheme.in === "query" && input.scheme.name) queryString.push({
|
|
1810
|
+
name: input.scheme.name,
|
|
1811
|
+
value: input.value
|
|
1513
1812
|
});
|
|
1514
1813
|
return queryString;
|
|
1515
1814
|
}
|
|
@@ -1557,15 +1856,14 @@ function getAuthorizationValue(auth) {
|
|
|
1557
1856
|
if (auth.scheme.type === "http" && auth.scheme.scheme?.toLowerCase() === "basic") return `Basic ${auth.value}`;
|
|
1558
1857
|
if (auth.scheme.type === "oauth2" || auth.scheme.type === "openIdConnect") return `Bearer ${auth.value}`;
|
|
1559
1858
|
}
|
|
1560
|
-
function
|
|
1561
|
-
if (!auth) return {};
|
|
1859
|
+
function getAuthHeader(auth) {
|
|
1562
1860
|
if (auth.scheme.type === "apiKey" && auth.scheme.in === "header" && auth.scheme.name) return { [auth.scheme.name]: auth.value };
|
|
1563
1861
|
const authorization = getAuthorizationValue(auth);
|
|
1564
1862
|
return authorization ? { Authorization: authorization } : {};
|
|
1565
1863
|
}
|
|
1566
|
-
function getRequestHeaders(requestContent, auth) {
|
|
1864
|
+
function getRequestHeaders(requestContent, auth = []) {
|
|
1567
1865
|
return {
|
|
1568
|
-
...
|
|
1866
|
+
...Object.assign({}, ...auth.map(getAuthHeader)),
|
|
1569
1867
|
Accept: "application/json",
|
|
1570
1868
|
...requestContent ? { "Content-Type": requestContent.mediaType } : {}
|
|
1571
1869
|
};
|
|
@@ -1883,6 +2181,10 @@ var requestSnippetOptions = [
|
|
|
1883
2181
|
}
|
|
1884
2182
|
];
|
|
1885
2183
|
function buildRequestCodeExamples(input) {
|
|
2184
|
+
const redactedInput = {
|
|
2185
|
+
...input,
|
|
2186
|
+
auth: redactAuth(input.auth)
|
|
2187
|
+
};
|
|
1886
2188
|
return requestSnippetOptions.map((option) => ({
|
|
1887
2189
|
key: `${option.languageKey}:${option.client}`,
|
|
1888
2190
|
title: option.title,
|
|
@@ -1890,7 +2192,7 @@ function buildRequestCodeExamples(input) {
|
|
|
1890
2192
|
languageKey: option.languageKey,
|
|
1891
2193
|
clientKey: option.client,
|
|
1892
2194
|
clientTitle: option.clientTitle,
|
|
1893
|
-
code: buildSnippet(
|
|
2195
|
+
code: buildSnippet(redactedInput, option)
|
|
1894
2196
|
}));
|
|
1895
2197
|
}
|
|
1896
2198
|
//#endregion
|
|
@@ -1902,7 +2204,7 @@ function SelectControl(arg0) {
|
|
|
1902
2204
|
label: option
|
|
1903
2205
|
} : option);
|
|
1904
2206
|
const selectedOption = normalizedOptions.find((option) => option.value === value) ?? normalizedOptions[0];
|
|
1905
|
-
const wrapperClassName = compact ? "clarify-
|
|
2207
|
+
const wrapperClassName = compact ? "clarify-openai-select relative min-w-0 text-xs" : "clarify-openai-select relative shrink-0 text-xs";
|
|
1906
2208
|
const buttonSizeClassName = compact ? "w-full min-w-0 max-w-32" : "min-w-28 max-w-48";
|
|
1907
2209
|
if (normalizedOptions.length <= 1) return null;
|
|
1908
2210
|
return /* @__PURE__ */ jsx(Listbox, {
|
|
@@ -1912,7 +2214,7 @@ function SelectControl(arg0) {
|
|
|
1912
2214
|
className: wrapperClassName,
|
|
1913
2215
|
children: [/* @__PURE__ */ jsxs(ListboxButton, {
|
|
1914
2216
|
"aria-label": label,
|
|
1915
|
-
className: `clarify-
|
|
2217
|
+
className: `clarify-openai-select-button flex min-h-8 ${buttonSizeClassName} items-center justify-between gap-2 rounded-(--clarify-theme-tokens-radius-md) 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-(--clarify-code-border) hover:bg-(--clarify-code-control-background-hover) focus:ring-2 focus:ring-(--clarify-ui-accent-border) data-open:border-(--clarify-code-border) data-open:bg-(--clarify-code-control-background-active) data-open:ring-2 data-open:ring-(--clarify-ui-accent-border)`,
|
|
1916
2218
|
children: [/* @__PURE__ */ jsxs("span", {
|
|
1917
2219
|
className: "flex min-w-0 items-center gap-1.5 overflow-hidden",
|
|
1918
2220
|
children: [icon ? /* @__PURE__ */ jsx("span", {
|
|
@@ -1928,10 +2230,10 @@ function SelectControl(arg0) {
|
|
|
1928
2230
|
})]
|
|
1929
2231
|
}), /* @__PURE__ */ jsx(ListboxOptions, {
|
|
1930
2232
|
anchor: "bottom end",
|
|
1931
|
-
className: "clarify-
|
|
2233
|
+
className: "clarify-openai-select-options z-30 mt-1 max-h-64 w-max min-w-(--button-width) max-w-(--clarify-popover-max-width) overflow-auto rounded-(--clarify-theme-tokens-radius-lg) 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",
|
|
1932
2234
|
children: normalizedOptions.map((option) => /* @__PURE__ */ jsxs(ListboxOption, {
|
|
1933
2235
|
value: option.value,
|
|
1934
|
-
className: "clarify-
|
|
2236
|
+
className: "clarify-openai-select-option group flex min-h-9 cursor-default items-center justify-between gap-3 rounded-(--clarify-theme-tokens-radius-md) 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)",
|
|
1935
2237
|
children: [/* @__PURE__ */ jsx("span", { children: option.label }), /* @__PURE__ */ jsx(CheckIcon, {
|
|
1936
2238
|
className: "h-3.5 w-3.5 shrink-0 opacity-0 group-data-selected:opacity-100",
|
|
1937
2239
|
"aria-hidden": "true"
|
|
@@ -1980,31 +2282,36 @@ function ExampleMetaValue(arg0) {
|
|
|
1980
2282
|
});
|
|
1981
2283
|
}
|
|
1982
2284
|
function CodeToolbar(arg0) {
|
|
1983
|
-
const { code, languageOptions, selectedLanguageKey, onSelectLanguage, clientOptions, selectedClientKey, onSelectClient } = arg0;
|
|
2285
|
+
const { code, leadingControls, languageOptions, selectedLanguageKey, onSelectLanguage, clientOptions, selectedClientKey, onSelectClient } = arg0;
|
|
1984
2286
|
const t = useBuiltInText();
|
|
2287
|
+
const inlineControls = Boolean(leadingControls);
|
|
1985
2288
|
return /* @__PURE__ */ jsxs("div", {
|
|
1986
|
-
className:
|
|
2289
|
+
className: `clarify-openai-code-toolbar flex items-center gap-2 px-4 pt-3${inlineControls ? " clarify-openai-code-toolbar-inline" : ""}`,
|
|
1987
2290
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
1988
|
-
className:
|
|
1989
|
-
children: [
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2291
|
+
className: `clarify-openai-code-toolbar-controls flex min-w-0 flex-1 items-center gap-2${inlineControls ? " flex-nowrap overflow-x-auto" : " flex-wrap"}`,
|
|
2292
|
+
children: [
|
|
2293
|
+
leadingControls,
|
|
2294
|
+
languageOptions && languageOptions.length > 1 && selectedLanguageKey && onSelectLanguage ? /* @__PURE__ */ jsx(SelectControl, {
|
|
2295
|
+
label: t("openapi.language"),
|
|
2296
|
+
value: selectedLanguageKey,
|
|
2297
|
+
options: languageOptions,
|
|
2298
|
+
onChange: onSelectLanguage,
|
|
2299
|
+
icon: /* @__PURE__ */ jsx(CodeIcon, {
|
|
2300
|
+
className: "h-3.5 w-3.5",
|
|
2301
|
+
"aria-hidden": "true"
|
|
2302
|
+
})
|
|
2303
|
+
}) : null,
|
|
2304
|
+
clientOptions && clientOptions.length > 1 && selectedClientKey && onSelectClient ? /* @__PURE__ */ jsx(SelectControl, {
|
|
2305
|
+
label: t("openapi.client"),
|
|
2306
|
+
value: selectedClientKey,
|
|
2307
|
+
options: clientOptions,
|
|
2308
|
+
onChange: onSelectClient,
|
|
2309
|
+
icon: /* @__PURE__ */ jsx(PackageIcon, {
|
|
2310
|
+
className: "h-3.5 w-3.5",
|
|
2311
|
+
"aria-hidden": "true"
|
|
2312
|
+
})
|
|
2313
|
+
}) : null
|
|
2314
|
+
]
|
|
2008
2315
|
}), /* @__PURE__ */ jsx(CopyCodeButton, { code })]
|
|
2009
2316
|
});
|
|
2010
2317
|
}
|
|
@@ -2040,12 +2347,17 @@ function getSecurityRequirements(spec, operation) {
|
|
|
2040
2347
|
}
|
|
2041
2348
|
function getAuthOptions(spec, operation) {
|
|
2042
2349
|
const schemes = getSecuritySchemes(spec);
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
scheme
|
|
2048
|
-
|
|
2350
|
+
return getSecurityRequirements(spec, operation).map((requirement, index) => {
|
|
2351
|
+
const requirementSchemes = Object.keys(requirement).map((name) => ({
|
|
2352
|
+
name,
|
|
2353
|
+
scheme: schemes[name]
|
|
2354
|
+
})).filter((option) => Boolean(option.scheme));
|
|
2355
|
+
return {
|
|
2356
|
+
key: `requirement:${index}`,
|
|
2357
|
+
label: requirementSchemes.map((option) => option.name).join(" + "),
|
|
2358
|
+
schemes: requirementSchemes
|
|
2359
|
+
};
|
|
2360
|
+
});
|
|
2049
2361
|
}
|
|
2050
2362
|
function authPlaceholder(auth) {
|
|
2051
2363
|
if (!auth) return "";
|
|
@@ -2076,21 +2388,38 @@ function getClientOptions(codeOptions, languageKey) {
|
|
|
2076
2388
|
//#endregion
|
|
2077
2389
|
//#region source/openapi/components/ExamplePanels.tsx
|
|
2078
2390
|
function ApiExampleCodeGroup(arg0) {
|
|
2079
|
-
const { title, tag, tagOptions, onSelectTag, label, labelOptions, onSelectLabel, comfortableMeta = false, code, language, mediaTypes, selectedMediaType, onSelectMediaType, examples, selectedExampleKey, onSelectExample, languageOptions, selectedLanguageKey, onSelectLanguage, clientOptions, selectedClientKey, onSelectClient } = arg0;
|
|
2391
|
+
const { title, tag, tagOptions, onSelectTag, label, labelOptions, onSelectLabel, comfortableMeta = false, metaInToolbar = false, code, language, mediaTypes, selectedMediaType, onSelectMediaType, examples, selectedExampleKey, onSelectExample, languageOptions, selectedLanguageKey, onSelectLanguage, clientOptions, selectedClientKey, onSelectClient } = arg0;
|
|
2080
2392
|
const t = useBuiltInText();
|
|
2081
|
-
const metaClassName = comfortableMeta ? "flex min-h-
|
|
2393
|
+
const metaClassName = comfortableMeta ? "flex min-h-10 min-w-0 items-center gap-2 border-b border-(--clarify-code-border) bg-(--clarify-code-background) px-3.5 py-2" : "flex h-9 min-w-0 items-center gap-2 border-b border-(--clarify-code-border) bg-(--clarify-code-background) px-3.5";
|
|
2394
|
+
const meta = /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
2395
|
+
tag ? /* @__PURE__ */ jsx(ExampleMetaValue, {
|
|
2396
|
+
label: t("openapi.status"),
|
|
2397
|
+
value: tag,
|
|
2398
|
+
options: tagOptions,
|
|
2399
|
+
onChange: onSelectTag,
|
|
2400
|
+
className: "clarify-openai-example-status font-semibold text-emerald-400"
|
|
2401
|
+
}) : null,
|
|
2402
|
+
tag && label ? /* @__PURE__ */ jsx("span", { className: "h-0.5 w-0.5 shrink-0 rounded-full bg-(--clarify-code-faint)" }) : null,
|
|
2403
|
+
label ? /* @__PURE__ */ jsx(ExampleMetaValue, {
|
|
2404
|
+
label: t("openapi.mediaType"),
|
|
2405
|
+
value: label,
|
|
2406
|
+
options: labelOptions,
|
|
2407
|
+
onChange: onSelectLabel,
|
|
2408
|
+
className: "min-w-0 truncate text-xs text-(--clarify-code-muted)"
|
|
2409
|
+
}) : null
|
|
2410
|
+
] });
|
|
2082
2411
|
return /* @__PURE__ */ jsx("div", {
|
|
2083
|
-
className: "clarify-
|
|
2412
|
+
className: "clarify-openai-example my-6 overflow-hidden rounded-lg border border-(--clarify-code-border) bg-(--clarify-code-background) shadow-sm",
|
|
2084
2413
|
children: /* @__PURE__ */ jsxs("div", {
|
|
2085
2414
|
className: "not-prose",
|
|
2086
2415
|
children: [
|
|
2087
2416
|
/* @__PURE__ */ jsxs("div", {
|
|
2088
|
-
className: "clarify-
|
|
2417
|
+
className: "clarify-openai-example-header flex min-h-11 items-center gap-3 border-b border-(--clarify-code-border) bg-(--clarify-code-header-background) px-3.5 py-1.5",
|
|
2089
2418
|
children: [/* @__PURE__ */ jsx("h3", {
|
|
2090
|
-
className: "mr-auto min-w-16 truncate py-1 text-
|
|
2419
|
+
className: "mr-auto min-w-16 truncate py-1 text-sm font-semibold text-(--clarify-code-text)",
|
|
2091
2420
|
children: title
|
|
2092
2421
|
}), /* @__PURE__ */ jsxs("div", {
|
|
2093
|
-
className: "clarify-
|
|
2422
|
+
className: "clarify-openai-example-header-controls ml-auto flex min-w-0 items-center gap-2 whitespace-nowrap",
|
|
2094
2423
|
children: [mediaTypes && mediaTypes.length > 1 && selectedMediaType && onSelectMediaType ? /* @__PURE__ */ jsx(SelectControl, {
|
|
2095
2424
|
label: t("openapi.mediaType"),
|
|
2096
2425
|
value: selectedMediaType,
|
|
@@ -2109,30 +2438,15 @@ function ApiExampleCodeGroup(arg0) {
|
|
|
2109
2438
|
}) : null]
|
|
2110
2439
|
})]
|
|
2111
2440
|
}),
|
|
2112
|
-
tag || label ? /* @__PURE__ */
|
|
2441
|
+
(tag || label) && !metaInToolbar ? /* @__PURE__ */ jsx("div", {
|
|
2113
2442
|
className: metaClassName,
|
|
2114
|
-
children:
|
|
2115
|
-
tag ? /* @__PURE__ */ jsx(ExampleMetaValue, {
|
|
2116
|
-
label: t("openapi.status"),
|
|
2117
|
-
value: tag,
|
|
2118
|
-
options: tagOptions,
|
|
2119
|
-
onChange: onSelectTag,
|
|
2120
|
-
className: "clarify-api-example-status font-semibold text-emerald-400"
|
|
2121
|
-
}) : null,
|
|
2122
|
-
tag && label ? /* @__PURE__ */ jsx("span", { className: "h-0.5 w-0.5 shrink-0 rounded-full bg-(--clarify-code-faint)" }) : null,
|
|
2123
|
-
label ? /* @__PURE__ */ jsx(ExampleMetaValue, {
|
|
2124
|
-
label: t("openapi.mediaType"),
|
|
2125
|
-
value: label,
|
|
2126
|
-
options: labelOptions,
|
|
2127
|
-
onChange: onSelectLabel,
|
|
2128
|
-
className: "min-w-0 truncate text-xs text-(--clarify-code-muted)"
|
|
2129
|
-
}) : null
|
|
2130
|
-
]
|
|
2443
|
+
children: meta
|
|
2131
2444
|
}) : null,
|
|
2132
2445
|
/* @__PURE__ */ jsxs("div", {
|
|
2133
|
-
className: "clarify-
|
|
2446
|
+
className: "clarify-openai-example-code group bg-(--clarify-code-background)",
|
|
2134
2447
|
children: [/* @__PURE__ */ jsx(CodeToolbar, {
|
|
2135
2448
|
code,
|
|
2449
|
+
leadingControls: metaInToolbar ? meta : void 0,
|
|
2136
2450
|
languageOptions,
|
|
2137
2451
|
selectedLanguageKey,
|
|
2138
2452
|
onSelectLanguage,
|
|
@@ -2328,6 +2642,9 @@ function ResponseExamplesPanel(arg0) {
|
|
|
2328
2642
|
if (!state.selectedContent || !state.responseBody) return null;
|
|
2329
2643
|
return /* @__PURE__ */ jsx(ApiExampleCodeGroup, {
|
|
2330
2644
|
title: title ?? t("openapi.response"),
|
|
2645
|
+
tag: state.selectedResponse?.status,
|
|
2646
|
+
tagOptions: state.responses.map((response) => response.status),
|
|
2647
|
+
onSelectTag: state.responses.length > 0 ? state.onSelectStatus : void 0,
|
|
2331
2648
|
label: state.selectedContent?.mediaType,
|
|
2332
2649
|
labelOptions: state.responseContents.map((content) => content.mediaType),
|
|
2333
2650
|
onSelectLabel: state.responseContents.length > 0 ? state.onSelectMediaType : void 0,
|
|
@@ -2335,7 +2652,8 @@ function ResponseExamplesPanel(arg0) {
|
|
|
2335
2652
|
language: codeLanguageForMediaType(state.selectedContent.mediaType),
|
|
2336
2653
|
examples: state.examples,
|
|
2337
2654
|
selectedExampleKey: state.selectedExample?.key,
|
|
2338
|
-
onSelectExample: state.onSelectExample
|
|
2655
|
+
onSelectExample: state.onSelectExample,
|
|
2656
|
+
metaInToolbar: true
|
|
2339
2657
|
});
|
|
2340
2658
|
}
|
|
2341
2659
|
//#endregion
|
|
@@ -2535,11 +2853,11 @@ function getRootSchemaNode(spec, schema, defaultExpanded) {
|
|
|
2535
2853
|
};
|
|
2536
2854
|
}
|
|
2537
2855
|
function EnumValueNode(arg0) {
|
|
2538
|
-
const { node
|
|
2856
|
+
const { node } = arg0;
|
|
2539
2857
|
return /* @__PURE__ */ jsx("li", {
|
|
2540
|
-
className: "clarify-schema-node m-0
|
|
2858
|
+
className: "clarify-schema-node m-0 p-0",
|
|
2541
2859
|
children: /* @__PURE__ */ jsx("div", {
|
|
2542
|
-
className:
|
|
2860
|
+
className: "flex min-w-0 items-start rounded-(--clarify-theme-tokens-radius-md) px-2 py-2 text-left",
|
|
2543
2861
|
children: /* @__PURE__ */ jsxs("div", {
|
|
2544
2862
|
className: "min-w-0 flex-1",
|
|
2545
2863
|
children: [/* @__PURE__ */ jsx("div", {
|
|
@@ -2573,7 +2891,7 @@ function SchemaNode(arg0) {
|
|
|
2573
2891
|
});
|
|
2574
2892
|
const type = [node.type, node.required ? t("openapi.requiredBadge") : void 0].filter(Boolean).join(", ") || void 0;
|
|
2575
2893
|
const fallbackDescription = hasChildren ? void 0 : node.required ? t("openapi.required") : t("openapi.optional");
|
|
2576
|
-
const rowClassName =
|
|
2894
|
+
const rowClassName = "flex w-full min-w-0 items-start rounded-(--clarify-theme-tokens-radius-md) px-2 py-2 text-left";
|
|
2577
2895
|
const content = /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("div", {
|
|
2578
2896
|
className: "min-w-0 flex-1",
|
|
2579
2897
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
@@ -2601,7 +2919,7 @@ function SchemaNode(arg0) {
|
|
|
2601
2919
|
children: expanded ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" })
|
|
2602
2920
|
}) : null] });
|
|
2603
2921
|
return /* @__PURE__ */ jsxs("li", {
|
|
2604
|
-
className: "clarify-schema-node m-0
|
|
2922
|
+
className: "clarify-schema-node m-0 p-0",
|
|
2605
2923
|
children: [hasChildren ? /* @__PURE__ */ jsx("button", {
|
|
2606
2924
|
type: "button",
|
|
2607
2925
|
"aria-label": expanded ? t("openapi.collapse") : t("openapi.expand"),
|
|
@@ -2623,7 +2941,7 @@ function SchemaTree(arg0) {
|
|
|
2623
2941
|
if (nodes.length === 0) return null;
|
|
2624
2942
|
return /* @__PURE__ */ jsx("ul", {
|
|
2625
2943
|
role: "list",
|
|
2626
|
-
className: clsx("m-0 list-none divide-y divide-(--clarify-theme-tokens-colors-border)
|
|
2944
|
+
className: clsx("m-0 list-none p-0", depth === 0 ? "divide-y divide-(--clarify-theme-tokens-colors-border)" : "ml-2 border-l border-(--clarify-theme-tokens-colors-border) pl-2"),
|
|
2627
2945
|
children: nodes.map((node) => /* @__PURE__ */ jsx(SchemaNode, {
|
|
2628
2946
|
node,
|
|
2629
2947
|
depth,
|
|
@@ -2636,7 +2954,7 @@ function SchemaProperties(arg0) {
|
|
|
2636
2954
|
const root = getRootSchemaNode(spec, schema, defaultExpanded);
|
|
2637
2955
|
if (!root || root.children.length === 0) return null;
|
|
2638
2956
|
return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", { children: title }), /* @__PURE__ */ jsx("div", {
|
|
2639
|
-
className: "clarify-schema-properties my-6",
|
|
2957
|
+
className: "clarify-schema-properties not-prose my-6",
|
|
2640
2958
|
children: /* @__PURE__ */ jsx(SchemaTree, { nodes: root.children })
|
|
2641
2959
|
})] });
|
|
2642
2960
|
}
|
|
@@ -2721,7 +3039,8 @@ function ResponseList(arg0) {
|
|
|
2721
3039
|
response
|
|
2722
3040
|
})
|
|
2723
3041
|
})),
|
|
2724
|
-
|
|
3042
|
+
className: "mt-4 mb-6",
|
|
3043
|
+
panelsClassName: "mt-5"
|
|
2725
3044
|
})] });
|
|
2726
3045
|
}
|
|
2727
3046
|
//#endregion
|
|
@@ -2746,7 +3065,7 @@ function EndpointRequest(arg0) {
|
|
|
2746
3065
|
})] });
|
|
2747
3066
|
};
|
|
2748
3067
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [renderDescription(), /* @__PURE__ */ jsxs(Row, {
|
|
2749
|
-
className: "relative mt-6",
|
|
3068
|
+
className: "clarify-openapi-request-workspace relative mt-8 pt-6",
|
|
2750
3069
|
children: [/* @__PURE__ */ jsx(Col, { children: /* @__PURE__ */ jsxs("div", {
|
|
2751
3070
|
className: "w-full",
|
|
2752
3071
|
children: [
|
|
@@ -2793,9 +3112,9 @@ function EndpointResponse(arg0) {
|
|
|
2793
3112
|
const responseTitle = operationSource === "webhook" ? t("openapi.webhookResponses") : t("openapi.responses");
|
|
2794
3113
|
const responseExampleTitle = operationSource === "webhook" ? t("openapi.webhookResponse") : t("openapi.response");
|
|
2795
3114
|
return /* @__PURE__ */ jsx("div", {
|
|
2796
|
-
className: "mt-6",
|
|
3115
|
+
className: "mt-10 pt-6",
|
|
2797
3116
|
children: /* @__PURE__ */ jsxs(Row, {
|
|
2798
|
-
className: "relative",
|
|
3117
|
+
className: "clarify-openapi-response-workspace relative",
|
|
2799
3118
|
children: [/* @__PURE__ */ jsx(Col, { children: /* @__PURE__ */ jsx("div", {
|
|
2800
3119
|
className: "w-full",
|
|
2801
3120
|
children: /* @__PURE__ */ jsx(ResponseList, {
|
|
@@ -2824,6 +3143,129 @@ function EndpointResponse(arg0) {
|
|
|
2824
3143
|
});
|
|
2825
3144
|
}
|
|
2826
3145
|
//#endregion
|
|
3146
|
+
//#region source/openapi/components/InlineListbox.tsx
|
|
3147
|
+
var defaultButtonClassName = "inline-flex min-w-0 items-center justify-between gap-1 border-0 bg-transparent font-medium text-(--clarify-ui-text-strong) outline-hidden transition hover:bg-(--clarify-ui-hover-background) focus:ring-2 focus:ring-inset focus:ring-(--clarify-theme-tokens-colors-primary) data-disabled:cursor-not-allowed data-open:bg-(--clarify-ui-active-background)";
|
|
3148
|
+
var optionsClassName = "z-30 mt-1 max-h-64 w-max min-w-(--button-width) max-w-(--clarify-popover-max-width) overflow-auto rounded-(--clarify-theme-tokens-radius-lg) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) p-1 text-xs shadow-lg shadow-black/10 [--anchor-gap:--spacing(1)] focus:outline-none";
|
|
3149
|
+
var optionClassName = "group flex min-h-9 cursor-default items-center justify-between gap-3 rounded-(--clarify-theme-tokens-radius-md) 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)";
|
|
3150
|
+
function OptionContent(arg0) {
|
|
3151
|
+
const { option } = arg0;
|
|
3152
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("span", {
|
|
3153
|
+
className: "min-w-0",
|
|
3154
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
3155
|
+
className: "block truncate",
|
|
3156
|
+
children: option.label
|
|
3157
|
+
}), option.description ? /* @__PURE__ */ jsx("span", {
|
|
3158
|
+
className: "mt-0.5 block truncate text-2xs text-(--clarify-ui-text-faint)",
|
|
3159
|
+
children: option.description
|
|
3160
|
+
}) : null]
|
|
3161
|
+
}), /* @__PURE__ */ jsx(CheckIcon, {
|
|
3162
|
+
className: "h-3.5 w-3.5 shrink-0 opacity-0 group-data-selected:opacity-100",
|
|
3163
|
+
"aria-hidden": "true"
|
|
3164
|
+
})] });
|
|
3165
|
+
}
|
|
3166
|
+
function InlineListbox(arg0) {
|
|
3167
|
+
const { label, value, options, onChange, compact = false, buttonContent, buttonClassName, className, invalid, describedBy, disabled = false } = arg0;
|
|
3168
|
+
const selected = options.find((option) => option.value === value);
|
|
3169
|
+
return /* @__PURE__ */ jsx(Listbox, {
|
|
3170
|
+
value,
|
|
3171
|
+
onChange,
|
|
3172
|
+
disabled,
|
|
3173
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
3174
|
+
className: clsx("pointer-events-auto relative inline-flex min-w-0 w-full", className),
|
|
3175
|
+
children: [/* @__PURE__ */ jsx(ListboxButton, {
|
|
3176
|
+
"aria-label": label,
|
|
3177
|
+
"aria-invalid": invalid || void 0,
|
|
3178
|
+
"aria-describedby": describedBy,
|
|
3179
|
+
className: clsx(buttonClassName ?? defaultButtonClassName, buttonClassName ? null : compact ? "min-h-7 max-w-32 px-2 py-0.5 text-xs" : "min-h-8 w-full px-2 text-xs"),
|
|
3180
|
+
children: buttonContent ?? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
|
|
3181
|
+
className: "truncate",
|
|
3182
|
+
children: selected?.label ?? (value || label)
|
|
3183
|
+
}), /* @__PURE__ */ jsx(ChevronDownIcon, {
|
|
3184
|
+
className: "h-3.5 w-3.5 shrink-0 text-(--clarify-ui-text-faint)",
|
|
3185
|
+
"aria-hidden": "true"
|
|
3186
|
+
})] })
|
|
3187
|
+
}), /* @__PURE__ */ jsx(ListboxOptions, {
|
|
3188
|
+
anchor: "bottom start",
|
|
3189
|
+
className: optionsClassName,
|
|
3190
|
+
children: options.map((option) => /* @__PURE__ */ jsx(ListboxOption, {
|
|
3191
|
+
value: option.value,
|
|
3192
|
+
className: optionClassName,
|
|
3193
|
+
children: /* @__PURE__ */ jsx(OptionContent, { option })
|
|
3194
|
+
}, option.value))
|
|
3195
|
+
})]
|
|
3196
|
+
})
|
|
3197
|
+
});
|
|
3198
|
+
}
|
|
3199
|
+
function MultiInlineListbox(arg0) {
|
|
3200
|
+
const { label, value, options, onChange, disabled = false, invalid, describedBy } = arg0;
|
|
3201
|
+
const selectedLabel = options.filter((option) => value.includes(option.value)).map((option) => option.label).join(", ");
|
|
3202
|
+
return /* @__PURE__ */ jsx(Listbox, {
|
|
3203
|
+
value,
|
|
3204
|
+
onChange,
|
|
3205
|
+
multiple: true,
|
|
3206
|
+
disabled,
|
|
3207
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
3208
|
+
className: "pointer-events-auto relative inline-flex min-w-0 w-full",
|
|
3209
|
+
children: [/* @__PURE__ */ jsxs(ListboxButton, {
|
|
3210
|
+
"aria-label": label,
|
|
3211
|
+
"aria-invalid": invalid || void 0,
|
|
3212
|
+
"aria-describedby": describedBy,
|
|
3213
|
+
className: clsx(defaultButtonClassName, "min-h-8 w-full px-2 text-xs"),
|
|
3214
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
3215
|
+
className: "truncate",
|
|
3216
|
+
children: selectedLabel || label
|
|
3217
|
+
}), /* @__PURE__ */ jsx(ChevronDownIcon, {
|
|
3218
|
+
className: "h-3.5 w-3.5 shrink-0 text-(--clarify-ui-text-faint)",
|
|
3219
|
+
"aria-hidden": "true"
|
|
3220
|
+
})]
|
|
3221
|
+
}), /* @__PURE__ */ jsx(ListboxOptions, {
|
|
3222
|
+
anchor: "bottom start",
|
|
3223
|
+
className: optionsClassName,
|
|
3224
|
+
children: options.map((option) => /* @__PURE__ */ jsx(ListboxOption, {
|
|
3225
|
+
value: option.value,
|
|
3226
|
+
className: optionClassName,
|
|
3227
|
+
children: /* @__PURE__ */ jsx(OptionContent, { option })
|
|
3228
|
+
}, option.value))
|
|
3229
|
+
})]
|
|
3230
|
+
})
|
|
3231
|
+
});
|
|
3232
|
+
}
|
|
3233
|
+
//#endregion
|
|
3234
|
+
//#region source/openapi/store.ts
|
|
3235
|
+
var credentialScopes = /* @__PURE__ */ new WeakMap();
|
|
3236
|
+
var emptyOpenApiCredentials = Object.freeze({});
|
|
3237
|
+
var nextCredentialScope = 0;
|
|
3238
|
+
function getOpenApiCredentialScope(spec) {
|
|
3239
|
+
const current = credentialScopes.get(spec);
|
|
3240
|
+
if (current) return current;
|
|
3241
|
+
const scope = `openapi-${nextCredentialScope += 1}`;
|
|
3242
|
+
credentialScopes.set(spec, scope);
|
|
3243
|
+
return scope;
|
|
3244
|
+
}
|
|
3245
|
+
var useOpenApiStore = create()((set) => ({
|
|
3246
|
+
credentials: {},
|
|
3247
|
+
setCredential: (scope, name, value) => set((state) => ({ credentials: {
|
|
3248
|
+
...state.credentials,
|
|
3249
|
+
[scope]: {
|
|
3250
|
+
...state.credentials[scope],
|
|
3251
|
+
[name]: value
|
|
3252
|
+
}
|
|
3253
|
+
} })),
|
|
3254
|
+
clearCredential: (scope, name) => set((state) => {
|
|
3255
|
+
const scoped = { ...state.credentials[scope] };
|
|
3256
|
+
delete scoped[name];
|
|
3257
|
+
return { credentials: {
|
|
3258
|
+
...state.credentials,
|
|
3259
|
+
[scope]: scoped
|
|
3260
|
+
} };
|
|
3261
|
+
}),
|
|
3262
|
+
clearCredentials: (scope) => set((state) => {
|
|
3263
|
+
const credentials = { ...state.credentials };
|
|
3264
|
+
delete credentials[scope];
|
|
3265
|
+
return { credentials };
|
|
3266
|
+
})
|
|
3267
|
+
}));
|
|
3268
|
+
//#endregion
|
|
2827
3269
|
//#region source/openapi/components/OpenApiOperation.state.ts
|
|
2828
3270
|
function useOperationRequestState(spec, path, operation, source = "path") {
|
|
2829
3271
|
const parameters = getOperationParameters(spec, path, operation, source);
|
|
@@ -2874,9 +3316,13 @@ function useOperationServerState(spec, operation, path, source = "path") {
|
|
|
2874
3316
|
}
|
|
2875
3317
|
function useOperationAuthState(spec, operation) {
|
|
2876
3318
|
const authOptions = getAuthOptions(spec, operation);
|
|
2877
|
-
const [selectedAuthName, setSelectedAuthName] = useState(authOptions[0]?.
|
|
2878
|
-
const selectedAuth = authOptions.find((option) => option.
|
|
2879
|
-
const
|
|
3319
|
+
const [selectedAuthName, setSelectedAuthName] = useState(authOptions[0]?.key ?? "");
|
|
3320
|
+
const selectedAuth = authOptions.find((option) => option.key === selectedAuthName);
|
|
3321
|
+
const credentialScope = getOpenApiCredentialScope(spec);
|
|
3322
|
+
const authValues = useOpenApiStore((state) => state.credentials[credentialScope] ?? emptyOpenApiCredentials);
|
|
3323
|
+
const setCredential = useOpenApiStore((state) => state.setCredential);
|
|
3324
|
+
const clearCredential = useOpenApiStore((state) => state.clearCredential);
|
|
3325
|
+
const clearCredentials = useOpenApiStore((state) => state.clearCredentials);
|
|
2880
3326
|
const [authOpen, setAuthOpen] = useState(false);
|
|
2881
3327
|
return {
|
|
2882
3328
|
authOptions,
|
|
@@ -2884,104 +3330,1302 @@ function useOperationAuthState(spec, operation) {
|
|
|
2884
3330
|
selectedAuth,
|
|
2885
3331
|
authValues,
|
|
2886
3332
|
authOpen,
|
|
2887
|
-
authInput: selectedAuth ? {
|
|
2888
|
-
name:
|
|
2889
|
-
scheme:
|
|
2890
|
-
value: authValues[
|
|
2891
|
-
} : void 0,
|
|
3333
|
+
authInput: selectedAuth ? selectedAuth.schemes.map((option) => ({
|
|
3334
|
+
name: option.name,
|
|
3335
|
+
scheme: option.scheme,
|
|
3336
|
+
value: authValues[option.name] ?? ""
|
|
3337
|
+
})) : void 0,
|
|
2892
3338
|
onSelectAuth: setSelectedAuthName,
|
|
2893
|
-
onChangeAuthValue: (name, value) =>
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
})),
|
|
3339
|
+
onChangeAuthValue: (name, value) => setCredential(credentialScope, name, value),
|
|
3340
|
+
onClearAuthValue: (name) => clearCredential(credentialScope, name),
|
|
3341
|
+
onClearAuthValues: () => clearCredentials(credentialScope),
|
|
2897
3342
|
onToggleAuth: () => setAuthOpen((current) => !current),
|
|
2898
3343
|
closeAuth: () => setAuthOpen(false)
|
|
2899
3344
|
};
|
|
2900
3345
|
}
|
|
2901
3346
|
//#endregion
|
|
2902
|
-
//#region source/openapi/
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
};
|
|
2911
|
-
function EndpointMethodBadge(arg0) {
|
|
2912
|
-
const { method } = arg0;
|
|
2913
|
-
return /* @__PURE__ */ jsx("span", {
|
|
2914
|
-
className: clsx("rounded-(--clarify-theme-tokens-radius-md) px-2.5 py-0.5 text-xs/6 font-black tracking-wide", endpointMethodStyleVars[method] ?? "bg-(--clarify-http-method-default-background) text-(--clarify-http-method-default-text)"),
|
|
2915
|
-
children: method
|
|
2916
|
-
});
|
|
3347
|
+
//#region source/openapi/lib/api-request.ts
|
|
3348
|
+
function parseBodyObject(body) {
|
|
3349
|
+
try {
|
|
3350
|
+
const parsed = JSON.parse(body);
|
|
3351
|
+
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : void 0;
|
|
3352
|
+
} catch {
|
|
3353
|
+
return;
|
|
3354
|
+
}
|
|
2917
3355
|
}
|
|
2918
|
-
function
|
|
2919
|
-
const
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
3356
|
+
function buildRequestBody(body, mediaType) {
|
|
3357
|
+
const values = parseBodyObject(body);
|
|
3358
|
+
if (mediaType.includes("application/x-www-form-urlencoded") && values) {
|
|
3359
|
+
const params = new URLSearchParams();
|
|
3360
|
+
Object.entries(values).forEach(([name, value]) => params.append(name, typeof value === "string" ? value : JSON.stringify(value)));
|
|
3361
|
+
return params;
|
|
3362
|
+
}
|
|
3363
|
+
if (mediaType.includes("multipart/form-data") && values) {
|
|
3364
|
+
const form = new FormData();
|
|
3365
|
+
Object.entries(values).forEach(([name, value]) => form.append(name, typeof value === "string" ? value : JSON.stringify(value)));
|
|
3366
|
+
return form;
|
|
3367
|
+
}
|
|
3368
|
+
return body;
|
|
3369
|
+
}
|
|
3370
|
+
function expandServerUrl(server, variables) {
|
|
3371
|
+
return (server.url ?? "").replace(/\{([^}]+)\}/g, (_, name) => variables[name] ?? server.variables?.[name]?.default ?? `{${name}}`);
|
|
3372
|
+
}
|
|
3373
|
+
function authorizationValue(auth) {
|
|
3374
|
+
const scheme = auth.scheme.scheme?.toLowerCase();
|
|
3375
|
+
if (auth.scheme.type === "http" && scheme === "basic") return `Basic ${auth.value}`;
|
|
3376
|
+
if (auth.scheme.type === "http" && scheme === "bearer") return `Bearer ${auth.value}`;
|
|
3377
|
+
if (auth.scheme.type === "oauth2" || auth.scheme.type === "openIdConnect") return `Bearer ${auth.value}`;
|
|
3378
|
+
}
|
|
3379
|
+
function parameterKey(parameter) {
|
|
3380
|
+
return `${parameter.in ?? "query"}:${parameter.name ?? ""}`;
|
|
3381
|
+
}
|
|
3382
|
+
function parseParameterValue(value) {
|
|
3383
|
+
const trimmed = value.trim();
|
|
3384
|
+
if (!trimmed || !trimmed.startsWith("[") && !trimmed.startsWith("{")) return value;
|
|
3385
|
+
try {
|
|
3386
|
+
return JSON.parse(trimmed);
|
|
3387
|
+
} catch {
|
|
3388
|
+
return value;
|
|
3389
|
+
}
|
|
3390
|
+
}
|
|
3391
|
+
function primitiveValue(value) {
|
|
3392
|
+
if (typeof value === "string") return value;
|
|
3393
|
+
if (value === null || typeof value === "undefined") return "";
|
|
3394
|
+
return String(value);
|
|
3395
|
+
}
|
|
3396
|
+
function serializedParameterValues(parameter, rawValue) {
|
|
3397
|
+
const value = parseParameterValue(rawValue);
|
|
3398
|
+
const style = parameter.style ?? (parameter.in === "query" || parameter.in === "cookie" ? "form" : "simple");
|
|
3399
|
+
const explode = parameter.explode ?? style === "form";
|
|
3400
|
+
if (Array.isArray(value)) {
|
|
3401
|
+
if (explode) return value.map((item) => [parameter.name ?? "", primitiveValue(item)]);
|
|
3402
|
+
const delimiter = style === "spaceDelimited" ? " " : style === "pipeDelimited" ? "|" : ",";
|
|
3403
|
+
return [[parameter.name ?? "", value.map(primitiveValue).join(delimiter)]];
|
|
3404
|
+
}
|
|
3405
|
+
if (typeof value === "object" && value !== null) {
|
|
3406
|
+
const entries = Object.entries(value);
|
|
3407
|
+
if (parameter.style === "deepObject") return entries.map(([key, item]) => [`${parameter.name}[${key}]`, primitiveValue(item)]);
|
|
3408
|
+
if (explode) return entries.map(([key, item]) => [key, primitiveValue(item)]);
|
|
3409
|
+
return [[parameter.name ?? "", entries.flatMap(([key, item]) => [key, primitiveValue(item)]).join(",")]];
|
|
3410
|
+
}
|
|
3411
|
+
return [[parameter.name ?? "", primitiveValue(value)]];
|
|
3412
|
+
}
|
|
3413
|
+
function pathParameterValue(parameter, rawValue) {
|
|
3414
|
+
const value = parseParameterValue(rawValue);
|
|
3415
|
+
const style = parameter.style ?? "simple";
|
|
3416
|
+
const explode = parameter.explode ?? false;
|
|
3417
|
+
const encode = (item) => encodeURIComponent(primitiveValue(item));
|
|
3418
|
+
if (Array.isArray(value)) {
|
|
3419
|
+
if (style === "label") return `.${value.map(encode).join(explode ? "." : ",")}`;
|
|
3420
|
+
if (style === "matrix") return explode ? value.map((item) => `;${parameter.name}=${encode(item)}`).join("") : `;${parameter.name}=${value.map(encode).join(",")}`;
|
|
3421
|
+
return value.map(encode).join(",");
|
|
3422
|
+
}
|
|
3423
|
+
if (typeof value === "object" && value !== null) {
|
|
3424
|
+
const entries = Object.entries(value);
|
|
3425
|
+
if (style === "label") return explode ? `.${entries.map(([key, item]) => `${encode(key)}=${encode(item)}`).join(".")}` : `.${entries.flatMap(([key, item]) => [encode(key), encode(item)]).join(",")}`;
|
|
3426
|
+
if (style === "matrix") return explode ? entries.map(([key, item]) => `;${encode(key)}=${encode(item)}`).join("") : `;${parameter.name}=${entries.flatMap(([key, item]) => [encode(key), encode(item)]).join(",")}`;
|
|
3427
|
+
return explode ? entries.map(([key, item]) => `${encode(key)}=${encode(item)}`).join(",") : entries.flatMap(([key, item]) => [encode(key), encode(item)]).join(",");
|
|
3428
|
+
}
|
|
3429
|
+
const encoded = encode(value);
|
|
3430
|
+
if (style === "label") return `.${encoded}`;
|
|
3431
|
+
if (style === "matrix") return `;${parameter.name}=${encoded}`;
|
|
3432
|
+
return encoded;
|
|
3433
|
+
}
|
|
3434
|
+
function headerParameterValue(parameter, rawValue) {
|
|
3435
|
+
const value = parseParameterValue(rawValue);
|
|
3436
|
+
if (Array.isArray(value)) return value.map(primitiveValue).join(",");
|
|
3437
|
+
if (typeof value === "object" && value !== null) {
|
|
3438
|
+
const entries = Object.entries(value);
|
|
3439
|
+
return parameter.explode ? entries.map(([key, item]) => `${key}=${primitiveValue(item)}`).join(",") : entries.flatMap(([key, item]) => [key, primitiveValue(item)]).join(",");
|
|
3440
|
+
}
|
|
3441
|
+
return primitiveValue(value);
|
|
3442
|
+
}
|
|
3443
|
+
function buildApiRequest(input) {
|
|
3444
|
+
const headers = new Headers({ Accept: "application/json" });
|
|
3445
|
+
const query = new URLSearchParams();
|
|
3446
|
+
let path = input.path;
|
|
3447
|
+
for (const parameter of input.parameters) {
|
|
3448
|
+
if (!parameter.name) continue;
|
|
3449
|
+
const key = parameterKey(parameter);
|
|
3450
|
+
if (input.parameterEnabled?.[key] === false) continue;
|
|
3451
|
+
const value = input.parameterValues[key] ?? "";
|
|
3452
|
+
if (!value && !parameter.allowEmptyValue) continue;
|
|
3453
|
+
if (parameter.in === "path") path = path.replaceAll(`{${parameter.name}}`, pathParameterValue(parameter, value));
|
|
3454
|
+
if (parameter.in === "query") serializedParameterValues(parameter, value).forEach(([name, item]) => query.append(name, item));
|
|
3455
|
+
if (parameter.in === "header") headers.set(parameter.name, headerParameterValue(parameter, value));
|
|
3456
|
+
}
|
|
3457
|
+
for (const auth of input.auth ?? []) {
|
|
3458
|
+
if (!auth.value) continue;
|
|
3459
|
+
if (auth.scheme.type === "apiKey" && auth.scheme.in === "query" && auth.scheme.name) query.set(auth.scheme.name, auth.value);
|
|
3460
|
+
else if (auth.scheme.type === "apiKey" && auth.scheme.in === "header" && auth.scheme.name) headers.set(auth.scheme.name, auth.value);
|
|
3461
|
+
else {
|
|
3462
|
+
const authorization = authorizationValue(auth);
|
|
3463
|
+
if (authorization) headers.set("Authorization", authorization);
|
|
3464
|
+
}
|
|
3465
|
+
}
|
|
3466
|
+
const url = new URL(joinPath(expandServerUrl(input.server, input.serverVariables ?? {}), path), input.baseUrl);
|
|
3467
|
+
query.forEach((value, key) => url.searchParams.append(key, value));
|
|
3468
|
+
const body = input.body?.trim();
|
|
3469
|
+
const mediaType = input.mediaType || "application/json";
|
|
3470
|
+
const requestBody = body && input.method.toUpperCase() !== "GET" && input.method.toUpperCase() !== "HEAD" ? buildRequestBody(body, mediaType) : void 0;
|
|
3471
|
+
if (requestBody && !(requestBody instanceof FormData)) headers.set("Content-Type", mediaType);
|
|
3472
|
+
return {
|
|
3473
|
+
url: url.toString(),
|
|
3474
|
+
init: {
|
|
3475
|
+
method: input.method.toUpperCase(),
|
|
3476
|
+
headers,
|
|
3477
|
+
credentials: "include",
|
|
3478
|
+
...requestBody ? { body: requestBody } : {}
|
|
3479
|
+
}
|
|
3480
|
+
};
|
|
3481
|
+
}
|
|
3482
|
+
//#endregion
|
|
3483
|
+
//#region source/openapi/components/OpenApiAuthPanel.tsx
|
|
3484
|
+
function OpenApiAuthPanel(arg0) {
|
|
3485
|
+
const { authOptions, selectedAuthName, selectedAuth, authValues, onSelectAuth, onChangeAuthValue, onClearAuthValue } = arg0;
|
|
3486
|
+
const t = useBuiltInText();
|
|
3487
|
+
if (authOptions.length === 0) return null;
|
|
3488
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
3489
|
+
className: "grid divide-y divide-(--clarify-theme-tokens-colors-border)",
|
|
3490
|
+
children: [/* @__PURE__ */ jsxs("label", {
|
|
3491
|
+
className: "grid min-w-0 grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",
|
|
3492
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
3493
|
+
className: "flex min-h-8 items-center border-r border-(--clarify-theme-tokens-colors-border) px-2 font-mono text-xs text-(--clarify-ui-text-strong)",
|
|
3494
|
+
children: "Auth"
|
|
3495
|
+
}), /* @__PURE__ */ jsx(InlineListbox, {
|
|
3496
|
+
label: "Auth",
|
|
3497
|
+
value: selectedAuthName,
|
|
3498
|
+
options: authOptions.map((option) => ({
|
|
3499
|
+
value: option.key,
|
|
3500
|
+
label: option.label || t("openapi.none")
|
|
3501
|
+
})),
|
|
3502
|
+
onChange: onSelectAuth
|
|
3503
|
+
})]
|
|
3504
|
+
}), selectedAuth?.schemes.map((option) => /* @__PURE__ */ jsxs("label", {
|
|
3505
|
+
className: "group grid min-w-0 grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",
|
|
3506
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
3507
|
+
className: "flex min-h-8 items-center border-r border-(--clarify-theme-tokens-colors-border) px-2 font-mono text-xs text-(--clarify-ui-text-strong)",
|
|
3508
|
+
children: authLabel(option.name, option.scheme)
|
|
3509
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
3510
|
+
className: "flex min-w-0 items-center focus-within:bg-(--clarify-ui-hover-background)",
|
|
3511
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
3512
|
+
type: "password",
|
|
3513
|
+
value: authValues[option.name] ?? "",
|
|
3514
|
+
placeholder: authPlaceholder(option),
|
|
3515
|
+
onChange: (event) => onChangeAuthValue(option.name, event.target.value),
|
|
3516
|
+
autoComplete: "off",
|
|
3517
|
+
className: "h-8 min-w-0 flex-1 border-0 bg-transparent px-2 text-xs text-(--clarify-theme-tokens-colors-foreground) outline-hidden placeholder:text-(--clarify-ui-text-faint)"
|
|
3518
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
3519
|
+
type: "button",
|
|
3520
|
+
onClick: () => onClearAuthValue(option.name),
|
|
3521
|
+
className: "mr-1 h-6 shrink-0 rounded-(--clarify-theme-tokens-radius-md) px-1 text-2xs font-medium text-(--clarify-ui-text-faint) opacity-0 transition-opacity hover:text-(--clarify-theme-tokens-colors-foreground) focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-(--clarify-theme-tokens-colors-primary) group-hover:opacity-100",
|
|
3522
|
+
children: t("openapi.clear")
|
|
3523
|
+
})]
|
|
3524
|
+
})]
|
|
3525
|
+
}, option.name))]
|
|
2943
3526
|
});
|
|
2944
3527
|
}
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
3528
|
+
//#endregion
|
|
3529
|
+
//#region source/openapi/components/OpenApiRequestFields.tsx
|
|
3530
|
+
function RequestField(arg0) {
|
|
3531
|
+
const { spec, parameter, value, enabled, onChange, onEnabledChange, issue } = arg0;
|
|
3532
|
+
const t = useBuiltInText();
|
|
3533
|
+
const schema = resolveSchema(spec, parameter.schema);
|
|
3534
|
+
const schemaRecord = isRecord$1(schema) ? schema : void 0;
|
|
3535
|
+
const itemSchema = isRecord$1(schemaRecord?.items) ? schemaRecord.items : void 0;
|
|
3536
|
+
const options = Array.isArray(schemaRecord?.enum) ? schemaRecord.enum.map(String) : [];
|
|
3537
|
+
const itemOptions = Array.isArray(itemSchema?.enum) ? itemSchema.enum.map(String) : [];
|
|
3538
|
+
const type = schemaToType(schema) ?? "string";
|
|
3539
|
+
const description = parameter.description ?? (typeof schemaRecord?.description === "string" ? schemaRecord.description : void 0);
|
|
3540
|
+
const structured = type.includes("[]") || type.includes("object");
|
|
3541
|
+
const boolean = type.includes("boolean");
|
|
3542
|
+
const numeric = type.includes("integer") || type.includes("number");
|
|
3543
|
+
const fieldId = `openapi-parameter-${parameter.in ?? "query"}-${parameter.name ?? ""}`.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
3544
|
+
const issueText = issue === "required" ? t("openapi.required") : issue ? t(`openapi.parameter${issue[0].toUpperCase()}${issue.slice(1)}`) : void 0;
|
|
3545
|
+
const controlProps = {
|
|
3546
|
+
"aria-label": parameter.name,
|
|
3547
|
+
"aria-invalid": issue ? true : void 0,
|
|
3548
|
+
"aria-describedby": issue ? `${fieldId}-issue` : void 0,
|
|
3549
|
+
disabled: !enabled
|
|
3550
|
+
};
|
|
3551
|
+
const arrayValue = (() => {
|
|
3552
|
+
try {
|
|
3553
|
+
const parsed = JSON.parse(value);
|
|
3554
|
+
return Array.isArray(parsed) ? parsed.map(String) : [];
|
|
3555
|
+
} catch {
|
|
3556
|
+
return [];
|
|
3557
|
+
}
|
|
3558
|
+
})();
|
|
3559
|
+
const descriptionTip = description ? /* @__PURE__ */ jsxs(Tooltip, {
|
|
3560
|
+
content: /* @__PURE__ */ jsx(Markdown, {
|
|
3561
|
+
className: "max-w-80 text-left *:first:mt-0 *:last:mb-0",
|
|
3562
|
+
children: description
|
|
3563
|
+
}),
|
|
3564
|
+
side: "bottom",
|
|
3565
|
+
className: "mr-1 shrink-0 [&>[role=tooltip]]:w-80 [&>[role=tooltip]]:max-w-[min(20rem,calc(100vw-2rem))] [&>[role=tooltip]]:border [&>[role=tooltip]]:border-(--clarify-theme-tokens-colors-border) [&>[role=tooltip]]:bg-(--clarify-theme-tokens-colors-surface) [&>[role=tooltip]]:p-3 [&>[role=tooltip]]:text-(--clarify-ui-text) [&>[role=tooltip]]:shadow-xl",
|
|
3566
|
+
triggerClassName: "clarify-field-description-trigger clarify-ui-control inline-flex size-7 items-center justify-center rounded-md !border-b-0 text-(--clarify-ui-text-faint) transition-colors",
|
|
3567
|
+
children: [/* @__PURE__ */ jsx(InfoIcon, {
|
|
3568
|
+
className: "size-4",
|
|
3569
|
+
"aria-hidden": "true"
|
|
3570
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
3571
|
+
className: "sr-only",
|
|
3572
|
+
children: t("openapi.fieldDescription")
|
|
3573
|
+
})]
|
|
3574
|
+
}) : null;
|
|
3575
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
3576
|
+
className: "group grid min-w-0 grid-cols-[2rem_minmax(0,1fr)] sm:grid-cols-[2rem_minmax(0,1fr)_minmax(0,1fr)] sm:items-stretch",
|
|
3577
|
+
children: [
|
|
3578
|
+
/* @__PURE__ */ jsx("div", {
|
|
3579
|
+
className: "flex min-h-8 items-center justify-center border-r border-(--clarify-theme-tokens-colors-border)",
|
|
3580
|
+
children: /* @__PURE__ */ jsx("input", {
|
|
3581
|
+
type: "checkbox",
|
|
3582
|
+
checked: enabled,
|
|
3583
|
+
disabled: parameter.required,
|
|
3584
|
+
onChange: (event) => onEnabledChange(event.target.checked),
|
|
3585
|
+
"aria-label": `${t("openapi.includeParameter")}: ${parameter.name ?? ""}`,
|
|
3586
|
+
className: "size-3.5 shrink-0 accent-(--clarify-theme-tokens-colors-primary) disabled:cursor-not-allowed"
|
|
3587
|
+
})
|
|
3588
|
+
}),
|
|
3589
|
+
/* @__PURE__ */ jsx("div", {
|
|
3590
|
+
className: "flex min-h-8 min-w-0 items-center border-r border-(--clarify-theme-tokens-colors-border) px-2",
|
|
3591
|
+
children: /* @__PURE__ */ jsxs("label", {
|
|
3592
|
+
htmlFor: fieldId,
|
|
3593
|
+
className: "flex min-w-0 flex-wrap items-center gap-x-1.5 text-xs text-(--clarify-ui-text-strong)",
|
|
3594
|
+
children: [
|
|
3595
|
+
/* @__PURE__ */ jsx("span", {
|
|
3596
|
+
className: "truncate font-mono",
|
|
3597
|
+
children: parameter.name
|
|
3598
|
+
}),
|
|
3599
|
+
/* @__PURE__ */ jsx("span", {
|
|
3600
|
+
className: "font-mono text-2xs text-(--clarify-ui-text-faint)",
|
|
3601
|
+
children: type
|
|
3602
|
+
}),
|
|
3603
|
+
parameter.required ? /* @__PURE__ */ jsx("span", {
|
|
3604
|
+
className: "text-(--clarify-error-accent-text)",
|
|
3605
|
+
children: "*"
|
|
3606
|
+
}) : null
|
|
3607
|
+
]
|
|
3608
|
+
})
|
|
3609
|
+
}),
|
|
3610
|
+
/* @__PURE__ */ jsxs("div", {
|
|
3611
|
+
className: clsx("col-start-2 flex min-w-0 items-center border-t border-(--clarify-theme-tokens-colors-border) sm:col-start-3 sm:row-start-1 sm:border-t-0", !enabled && "opacity-45"),
|
|
3612
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
3613
|
+
className: "min-w-0 flex-1",
|
|
3614
|
+
children: itemOptions.length > 0 ? /* @__PURE__ */ jsx(MultiInlineListbox, {
|
|
3615
|
+
label: parameter.name ?? "",
|
|
3616
|
+
value: arrayValue,
|
|
3617
|
+
options: itemOptions.map((option) => ({
|
|
3618
|
+
value: option,
|
|
3619
|
+
label: option
|
|
3620
|
+
})),
|
|
3621
|
+
onChange: (next) => onChange(JSON.stringify(next)),
|
|
3622
|
+
invalid: Boolean(issue),
|
|
3623
|
+
describedBy: issue ? `${fieldId}-issue` : void 0,
|
|
3624
|
+
disabled: !enabled
|
|
3625
|
+
}) : options.length > 0 ? /* @__PURE__ */ jsx(InlineListbox, {
|
|
3626
|
+
label: parameter.name ?? "",
|
|
3627
|
+
value,
|
|
3628
|
+
options: [...parameter.required ? [] : [{
|
|
3629
|
+
value: "",
|
|
3630
|
+
label: t("openapi.none")
|
|
3631
|
+
}], ...options.map((option) => ({
|
|
3632
|
+
value: option,
|
|
3633
|
+
label: option
|
|
3634
|
+
}))],
|
|
3635
|
+
onChange,
|
|
3636
|
+
invalid: Boolean(issue),
|
|
3637
|
+
describedBy: issue ? `${fieldId}-issue` : void 0,
|
|
3638
|
+
disabled: !enabled
|
|
3639
|
+
}) : boolean ? /* @__PURE__ */ jsx("input", {
|
|
3640
|
+
...controlProps,
|
|
3641
|
+
id: fieldId,
|
|
3642
|
+
type: "checkbox",
|
|
3643
|
+
checked: value === "true",
|
|
3644
|
+
onChange: (event) => onChange(String(event.target.checked)),
|
|
3645
|
+
className: "size-4 accent-(--clarify-theme-tokens-colors-primary)"
|
|
3646
|
+
}) : structured ? /* @__PURE__ */ jsx("textarea", {
|
|
3647
|
+
...controlProps,
|
|
3648
|
+
id: fieldId,
|
|
3649
|
+
value,
|
|
3650
|
+
required: parameter.required,
|
|
3651
|
+
onChange: (event) => onChange(event.target.value),
|
|
3652
|
+
rows: 3,
|
|
3653
|
+
spellCheck: false,
|
|
3654
|
+
placeholder: type.includes("[]") ? "[]" : "{}",
|
|
3655
|
+
className: "w-full resize-y border-0 bg-transparent p-2 font-mono text-xs/5 text-(--clarify-theme-tokens-colors-foreground) outline-hidden aria-invalid:text-(--clarify-error-accent-text) focus:bg-(--clarify-ui-hover-background)"
|
|
3656
|
+
}) : /* @__PURE__ */ jsx("input", {
|
|
3657
|
+
...controlProps,
|
|
3658
|
+
id: fieldId,
|
|
3659
|
+
value,
|
|
3660
|
+
type: numeric ? "number" : schemaRecord?.format === "date" ? "date" : schemaRecord?.format === "date-time" ? "datetime-local" : "text",
|
|
3661
|
+
required: parameter.required,
|
|
3662
|
+
onChange: (event) => onChange(event.target.value),
|
|
3663
|
+
className: "h-8 w-full border-0 bg-transparent px-2 font-mono text-xs text-(--clarify-theme-tokens-colors-foreground) outline-hidden transition placeholder:text-(--clarify-ui-text-faint) focus:bg-(--clarify-ui-hover-background) aria-invalid:text-(--clarify-error-accent-text)"
|
|
3664
|
+
})
|
|
3665
|
+
}), descriptionTip]
|
|
3666
|
+
}),
|
|
3667
|
+
issueText ? /* @__PURE__ */ jsx("span", {
|
|
3668
|
+
id: `${fieldId}-issue`,
|
|
3669
|
+
className: "col-start-2 border-t border-(--clarify-theme-tokens-colors-border) px-2 py-1 text-xs/5 font-medium text-(--clarify-error-accent-text) sm:col-start-3",
|
|
3670
|
+
children: issueText
|
|
3671
|
+
}) : null
|
|
3672
|
+
]
|
|
3673
|
+
});
|
|
3674
|
+
}
|
|
3675
|
+
function RequestSection(arg0) {
|
|
3676
|
+
const { title, count, defaultOpen, actions, className, contentClassName, children } = arg0;
|
|
3677
|
+
return /* @__PURE__ */ jsxs("details", {
|
|
3678
|
+
open: defaultOpen,
|
|
3679
|
+
className: clsx("group shrink-0 border-b border-(--clarify-theme-tokens-colors-border)", className),
|
|
3680
|
+
children: [/* @__PURE__ */ jsxs("summary", {
|
|
3681
|
+
className: "flex min-h-11 cursor-pointer list-none items-center gap-2 bg-(--clarify-ui-subtle-background) px-2.5 text-sm font-medium text-(--clarify-ui-text-strong) hover:bg-(--clarify-ui-hover-background) group-open:border-b group-open:border-(--clarify-theme-tokens-colors-border)",
|
|
3682
|
+
children: [
|
|
3683
|
+
/* @__PURE__ */ jsx(ChevronDownIcon, {
|
|
3684
|
+
className: "size-4 shrink-0 -rotate-90 transition group-open:rotate-0",
|
|
3685
|
+
"aria-hidden": "true"
|
|
3686
|
+
}),
|
|
3687
|
+
/* @__PURE__ */ jsx("span", {
|
|
3688
|
+
className: "flex-1",
|
|
3689
|
+
children: title
|
|
3690
|
+
}),
|
|
3691
|
+
typeof count === "number" ? /* @__PURE__ */ jsx("span", {
|
|
3692
|
+
className: "font-mono text-xs text-(--clarify-ui-text-faint)",
|
|
3693
|
+
children: count
|
|
3694
|
+
}) : null,
|
|
3695
|
+
actions ? /* @__PURE__ */ jsx("span", {
|
|
3696
|
+
className: "flex items-center gap-1",
|
|
3697
|
+
onClick: (event) => {
|
|
3698
|
+
event.preventDefault();
|
|
3699
|
+
event.stopPropagation();
|
|
3700
|
+
},
|
|
3701
|
+
children: actions
|
|
3702
|
+
}) : null
|
|
3703
|
+
]
|
|
3704
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
3705
|
+
className: clsx("divide-y divide-(--clarify-theme-tokens-colors-border)", contentClassName),
|
|
3706
|
+
children
|
|
3707
|
+
})]
|
|
3708
|
+
});
|
|
3709
|
+
}
|
|
3710
|
+
//#endregion
|
|
3711
|
+
//#region source/openapi/components/OpenApiResponseViewer.tsx
|
|
3712
|
+
function formatBytes(size) {
|
|
3713
|
+
if (size < 1024) return `${size} B`;
|
|
3714
|
+
if (size < 1024 * 1024) return `${(size / 1024).toFixed(1)} KB`;
|
|
3715
|
+
return `${(size / (1024 * 1024)).toFixed(1)} MB`;
|
|
3716
|
+
}
|
|
3717
|
+
function parseJson(value) {
|
|
3718
|
+
try {
|
|
3719
|
+
return JSON.parse(value);
|
|
3720
|
+
} catch {
|
|
3721
|
+
return;
|
|
3722
|
+
}
|
|
3723
|
+
}
|
|
3724
|
+
function ResponseState(arg0) {
|
|
3725
|
+
const { icon: Icon, title, description, tone = "default" } = arg0;
|
|
3726
|
+
const error = tone === "error";
|
|
3727
|
+
return /* @__PURE__ */ jsx("div", {
|
|
3728
|
+
className: "grid min-h-56 flex-1 place-items-center px-6 py-10 text-center",
|
|
3729
|
+
role: error ? "alert" : "status",
|
|
2951
3730
|
children: /* @__PURE__ */ jsxs("div", {
|
|
2952
|
-
className: "
|
|
2953
|
-
children: [
|
|
2954
|
-
"
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
3731
|
+
className: "max-w-sm",
|
|
3732
|
+
children: [
|
|
3733
|
+
/* @__PURE__ */ jsx("span", {
|
|
3734
|
+
className: clsx("mx-auto mb-3 grid size-10 place-items-center rounded-full border", error ? "border-(--clarify-code-danger-border) bg-(--clarify-code-danger-background) text-(--clarify-code-danger)" : "border-(--clarify-code-border) bg-(--clarify-code-control-background) text-(--clarify-code-muted)"),
|
|
3735
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
3736
|
+
className: "size-4.5",
|
|
3737
|
+
"aria-hidden": "true"
|
|
3738
|
+
})
|
|
3739
|
+
}),
|
|
3740
|
+
/* @__PURE__ */ jsx("p", {
|
|
3741
|
+
className: clsx("text-sm font-semibold", error ? "text-(--clarify-code-danger)" : "text-(--clarify-code-text)"),
|
|
3742
|
+
children: title
|
|
3743
|
+
}),
|
|
3744
|
+
/* @__PURE__ */ jsx("p", {
|
|
3745
|
+
className: "mt-1 text-xs/5 text-(--clarify-code-faint)",
|
|
3746
|
+
children: description
|
|
3747
|
+
})
|
|
3748
|
+
]
|
|
3749
|
+
})
|
|
3750
|
+
});
|
|
3751
|
+
}
|
|
3752
|
+
function JsonPreview(arg0) {
|
|
3753
|
+
const { value } = arg0;
|
|
3754
|
+
if (Array.isArray(value)) return /* @__PURE__ */ jsx("div", {
|
|
3755
|
+
className: "space-y-1 border-l border-(--clarify-code-border) pl-3",
|
|
3756
|
+
children: value.map((item, index) => /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("span", {
|
|
3757
|
+
className: "mr-2 text-(--clarify-code-faint)",
|
|
3758
|
+
children: index
|
|
3759
|
+
}), /* @__PURE__ */ jsx(JsonPreview, { value: item })] }, index))
|
|
3760
|
+
});
|
|
3761
|
+
if (isRecord$1(value)) return /* @__PURE__ */ jsx("div", {
|
|
3762
|
+
className: "space-y-1 border-l border-(--clarify-code-border) pl-3",
|
|
3763
|
+
children: Object.entries(value).map(([key, item]) => /* @__PURE__ */ jsxs("div", {
|
|
3764
|
+
className: "grid grid-cols-[minmax(5rem,auto)_1fr] gap-3",
|
|
3765
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
3766
|
+
className: "text-(--clarify-code-property)",
|
|
3767
|
+
children: key
|
|
3768
|
+
}), /* @__PURE__ */ jsx(JsonPreview, { value: item })]
|
|
3769
|
+
}, key))
|
|
3770
|
+
});
|
|
3771
|
+
if (value === null) return /* @__PURE__ */ jsx("span", {
|
|
3772
|
+
className: "text-(--clarify-code-faint)",
|
|
3773
|
+
children: "null"
|
|
3774
|
+
});
|
|
3775
|
+
if (typeof value === "string") return /* @__PURE__ */ jsx("span", {
|
|
3776
|
+
className: "wrap-break-word text-(--clarify-code-string)",
|
|
3777
|
+
children: value
|
|
3778
|
+
});
|
|
3779
|
+
return /* @__PURE__ */ jsx("span", {
|
|
3780
|
+
className: "text-(--clarify-code-number)",
|
|
3781
|
+
children: String(value)
|
|
3782
|
+
});
|
|
3783
|
+
}
|
|
3784
|
+
function CopyButton(arg0) {
|
|
3785
|
+
const { value } = arg0;
|
|
3786
|
+
const t = useBuiltInText();
|
|
3787
|
+
const [copied, setCopied] = useState(false);
|
|
3788
|
+
async function copy() {
|
|
3789
|
+
const success = await copyTextToClipboard(value);
|
|
3790
|
+
setCopied(success);
|
|
3791
|
+
if (success) window.setTimeout(() => setCopied(false), 1600);
|
|
3792
|
+
}
|
|
3793
|
+
return /* @__PURE__ */ jsx("button", {
|
|
3794
|
+
type: "button",
|
|
3795
|
+
onClick: copy,
|
|
3796
|
+
"aria-label": copied ? t("actions.copied") : t("actions.copy"),
|
|
3797
|
+
title: copied ? t("actions.copied") : t("actions.copy"),
|
|
3798
|
+
className: "grid size-8 shrink-0 place-items-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-code-muted) hover:bg-(--clarify-code-control-background-hover) hover:text-(--clarify-code-text) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
|
|
3799
|
+
children: copied ? /* @__PURE__ */ jsx(CheckIcon, {
|
|
3800
|
+
className: "size-4 text-(--clarify-code-success)",
|
|
3801
|
+
"aria-hidden": "true"
|
|
3802
|
+
}) : /* @__PURE__ */ jsx(CopyIcon, {
|
|
3803
|
+
className: "size-4",
|
|
3804
|
+
"aria-hidden": "true"
|
|
3805
|
+
})
|
|
3806
|
+
});
|
|
3807
|
+
}
|
|
3808
|
+
function ResponseMedia(arg0) {
|
|
3809
|
+
const { blob, type } = arg0;
|
|
3810
|
+
const elementRef = useRef(null);
|
|
3811
|
+
useEffect(() => {
|
|
3812
|
+
const element = elementRef.current;
|
|
3813
|
+
if (!element) return;
|
|
3814
|
+
const url = URL.createObjectURL(blob);
|
|
3815
|
+
element.src = url;
|
|
3816
|
+
return () => {
|
|
3817
|
+
element.removeAttribute("src");
|
|
3818
|
+
URL.revokeObjectURL(url);
|
|
3819
|
+
};
|
|
3820
|
+
}, [blob]);
|
|
3821
|
+
if (type === "image") return /* @__PURE__ */ jsx("img", {
|
|
3822
|
+
ref: elementRef,
|
|
3823
|
+
alt: "",
|
|
3824
|
+
className: "max-h-128 max-w-full object-contain"
|
|
3825
|
+
});
|
|
3826
|
+
if (type === "audio") return /* @__PURE__ */ jsx("audio", {
|
|
3827
|
+
ref: elementRef,
|
|
3828
|
+
controls: true,
|
|
3829
|
+
className: "w-full"
|
|
3830
|
+
});
|
|
3831
|
+
return /* @__PURE__ */ jsx("video", {
|
|
3832
|
+
ref: elementRef,
|
|
3833
|
+
controls: true,
|
|
3834
|
+
className: "max-h-128 max-w-full"
|
|
3835
|
+
});
|
|
3836
|
+
}
|
|
3837
|
+
function ResponsePreview(arg0) {
|
|
3838
|
+
const { exchange } = arg0;
|
|
3839
|
+
const t = useBuiltInText();
|
|
3840
|
+
const contentType = exchange.contentType.toLowerCase();
|
|
3841
|
+
if (!exchange.size) return /* @__PURE__ */ jsx(ResponseState, {
|
|
3842
|
+
icon: FileX2Icon,
|
|
3843
|
+
title: t("openapi.responseBodyEmptyTitle"),
|
|
3844
|
+
description: t("openapi.responseBodyEmpty")
|
|
3845
|
+
});
|
|
3846
|
+
if (contentType.includes("json")) {
|
|
3847
|
+
const parsed = parseJson(exchange.body);
|
|
3848
|
+
return typeof parsed === "undefined" ? /* @__PURE__ */ jsx("pre", {
|
|
3849
|
+
className: "whitespace-pre-wrap wrap-break-word font-mono text-xs/5",
|
|
3850
|
+
children: exchange.body
|
|
3851
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
3852
|
+
className: "overflow-auto font-mono text-xs/5",
|
|
3853
|
+
children: /* @__PURE__ */ jsx(JsonPreview, { value: parsed })
|
|
3854
|
+
});
|
|
3855
|
+
}
|
|
3856
|
+
if (contentType.startsWith("image/")) return /* @__PURE__ */ jsx(ResponseMedia, {
|
|
3857
|
+
blob: exchange.blob,
|
|
3858
|
+
type: "image"
|
|
3859
|
+
});
|
|
3860
|
+
if (contentType.startsWith("audio/")) return /* @__PURE__ */ jsx(ResponseMedia, {
|
|
3861
|
+
blob: exchange.blob,
|
|
3862
|
+
type: "audio"
|
|
3863
|
+
});
|
|
3864
|
+
if (contentType.startsWith("video/")) return /* @__PURE__ */ jsx(ResponseMedia, {
|
|
3865
|
+
blob: exchange.blob,
|
|
3866
|
+
type: "video"
|
|
3867
|
+
});
|
|
3868
|
+
if (contentType.includes("html")) return /* @__PURE__ */ jsx("iframe", {
|
|
3869
|
+
srcDoc: exchange.body,
|
|
3870
|
+
sandbox: "",
|
|
3871
|
+
title: "Response preview",
|
|
3872
|
+
className: "h-96 w-full border-0 bg-white"
|
|
3873
|
+
});
|
|
3874
|
+
if (contentType.startsWith("text/") || contentType.includes("xml") || contentType.includes("yaml")) return /* @__PURE__ */ jsx("pre", {
|
|
3875
|
+
className: "whitespace-pre-wrap wrap-break-word font-mono text-xs/5",
|
|
3876
|
+
children: exchange.body
|
|
3877
|
+
});
|
|
3878
|
+
return /* @__PURE__ */ jsx("div", {
|
|
3879
|
+
className: "grid min-h-56 place-items-center text-xs text-(--clarify-code-faint)",
|
|
3880
|
+
children: t("openapi.binaryPreview")
|
|
3881
|
+
});
|
|
3882
|
+
}
|
|
3883
|
+
function ResponseHeaders(arg0) {
|
|
3884
|
+
const { headers: sourceHeaders } = arg0;
|
|
3885
|
+
const t = useBuiltInText();
|
|
3886
|
+
const [query, setQuery] = useState("");
|
|
3887
|
+
const normalizedQuery = query.trim().toLowerCase();
|
|
3888
|
+
const headers = normalizedQuery ? sourceHeaders.filter(([name, value]) => `${name} ${value}`.toLowerCase().includes(normalizedQuery)) : sourceHeaders;
|
|
3889
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
3890
|
+
/* @__PURE__ */ jsxs("label", {
|
|
3891
|
+
className: "flex h-9 items-center gap-2 border-b border-(--clarify-code-border) bg-(--clarify-code-control-background) px-3",
|
|
3892
|
+
children: [
|
|
3893
|
+
/* @__PURE__ */ jsx(SearchIcon, {
|
|
3894
|
+
className: "size-4 shrink-0 text-(--clarify-code-muted)",
|
|
2961
3895
|
"aria-hidden": "true"
|
|
2962
|
-
})
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
3896
|
+
}),
|
|
3897
|
+
/* @__PURE__ */ jsx("span", {
|
|
3898
|
+
className: "sr-only",
|
|
3899
|
+
children: t("openapi.searchHeaders")
|
|
3900
|
+
}),
|
|
3901
|
+
/* @__PURE__ */ jsx("input", {
|
|
3902
|
+
value: query,
|
|
3903
|
+
onChange: (event) => setQuery(event.target.value),
|
|
3904
|
+
placeholder: t("openapi.searchHeaders"),
|
|
3905
|
+
className: "min-w-0 flex-1 bg-transparent text-xs text-(--clarify-code-text) outline-none placeholder:text-(--clarify-code-faint)"
|
|
3906
|
+
})
|
|
3907
|
+
]
|
|
3908
|
+
}),
|
|
3909
|
+
/* @__PURE__ */ jsx("div", {
|
|
3910
|
+
className: "overflow-x-auto",
|
|
3911
|
+
children: /* @__PURE__ */ jsxs("table", {
|
|
3912
|
+
className: "w-full min-w-96 table-fixed border-collapse text-left font-mono text-xs/5",
|
|
3913
|
+
children: [/* @__PURE__ */ jsx("thead", {
|
|
3914
|
+
className: "bg-(--clarify-code-control-background) text-(--clarify-code-muted)",
|
|
3915
|
+
children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
3916
|
+
/* @__PURE__ */ jsx("th", {
|
|
3917
|
+
className: "w-2/5 border-r border-(--clarify-code-border) px-3 py-2 font-semibold",
|
|
3918
|
+
children: t("openapi.headerName")
|
|
3919
|
+
}),
|
|
3920
|
+
/* @__PURE__ */ jsx("th", {
|
|
3921
|
+
className: "px-3 py-2 font-semibold",
|
|
3922
|
+
children: t("openapi.headerValue")
|
|
3923
|
+
}),
|
|
3924
|
+
/* @__PURE__ */ jsx("th", {
|
|
3925
|
+
className: "w-10",
|
|
3926
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
3927
|
+
className: "sr-only",
|
|
3928
|
+
children: t("actions.copy")
|
|
3929
|
+
})
|
|
3930
|
+
})
|
|
3931
|
+
] })
|
|
3932
|
+
}), /* @__PURE__ */ jsx("tbody", { children: headers.map(([name, value], index) => /* @__PURE__ */ jsxs("tr", {
|
|
3933
|
+
className: "border-t border-(--clarify-code-border) hover:bg-(--clarify-code-control-background)",
|
|
3934
|
+
children: [
|
|
3935
|
+
/* @__PURE__ */ jsx("td", {
|
|
3936
|
+
className: "break-all border-r border-(--clarify-code-border) px-3 py-2 align-top text-(--clarify-code-property)",
|
|
3937
|
+
children: name
|
|
3938
|
+
}),
|
|
3939
|
+
/* @__PURE__ */ jsx("td", {
|
|
3940
|
+
className: "break-all px-3 py-2 align-top text-(--clarify-code-text)",
|
|
3941
|
+
children: value
|
|
3942
|
+
}),
|
|
3943
|
+
/* @__PURE__ */ jsx("td", {
|
|
3944
|
+
className: "pr-1",
|
|
3945
|
+
children: /* @__PURE__ */ jsx(CopyButton, { value: `${name}: ${value}` })
|
|
3946
|
+
})
|
|
3947
|
+
]
|
|
3948
|
+
}, `${name}:${index}`)) })]
|
|
3949
|
+
})
|
|
3950
|
+
}),
|
|
3951
|
+
headers.length === 0 ? /* @__PURE__ */ jsx("p", {
|
|
3952
|
+
className: "border-t border-(--clarify-code-border) py-8 text-center text-xs text-(--clarify-code-faint)",
|
|
3953
|
+
children: t("openapi.noHeaders")
|
|
3954
|
+
}) : null
|
|
3955
|
+
] });
|
|
3956
|
+
}
|
|
3957
|
+
function HiddenCookies() {
|
|
3958
|
+
const t = useBuiltInText();
|
|
3959
|
+
return /* @__PURE__ */ jsxs("table", {
|
|
3960
|
+
className: "w-full table-fixed border-collapse text-left text-xs/5",
|
|
3961
|
+
children: [/* @__PURE__ */ jsx("thead", {
|
|
3962
|
+
className: "bg-(--clarify-code-control-background) text-(--clarify-code-muted)",
|
|
3963
|
+
children: /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("th", {
|
|
3964
|
+
className: "w-2/5 border-r border-(--clarify-code-border) px-3 py-2 font-semibold",
|
|
3965
|
+
children: t("openapi.headerName")
|
|
3966
|
+
}), /* @__PURE__ */ jsx("th", {
|
|
3967
|
+
className: "px-3 py-2 font-semibold",
|
|
3968
|
+
children: t("openapi.headerValue")
|
|
3969
|
+
})] })
|
|
3970
|
+
}), /* @__PURE__ */ jsx("tbody", { children: /* @__PURE__ */ jsx("tr", {
|
|
3971
|
+
className: "border-t border-(--clarify-code-border)",
|
|
3972
|
+
children: /* @__PURE__ */ jsx("td", {
|
|
3973
|
+
colSpan: 2,
|
|
3974
|
+
className: "px-3 py-5 text-center text-(--clarify-code-faint)",
|
|
3975
|
+
children: t("openapi.cookiesBrowserHidden")
|
|
3976
|
+
})
|
|
3977
|
+
}) })]
|
|
3978
|
+
});
|
|
3979
|
+
}
|
|
3980
|
+
function OpenApiResponseViewer(arg0) {
|
|
3981
|
+
const { exchange, error } = arg0;
|
|
3982
|
+
const t = useBuiltInText();
|
|
3983
|
+
const [bodyMode, setBodyMode] = useState("preview");
|
|
3984
|
+
function downloadBody() {
|
|
3985
|
+
if (!exchange) return;
|
|
3986
|
+
const url = URL.createObjectURL(exchange.blob);
|
|
3987
|
+
const anchor = document.createElement("a");
|
|
3988
|
+
anchor.href = url;
|
|
3989
|
+
anchor.download = `response.${exchange.contentType.includes("json") ? "json" : "bin"}`;
|
|
3990
|
+
anchor.click();
|
|
3991
|
+
URL.revokeObjectURL(url);
|
|
3992
|
+
}
|
|
3993
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
3994
|
+
className: "clarify-api-response flex h-full min-h-96 min-w-0 flex-col bg-(--clarify-code-background) text-(--clarify-code-text)",
|
|
3995
|
+
"aria-label": t("openapi.response"),
|
|
3996
|
+
children: [
|
|
3997
|
+
/* @__PURE__ */ jsxs("div", {
|
|
3998
|
+
className: "sticky top-0 z-10 flex min-h-11 flex-wrap items-center gap-2 border-b border-(--clarify-code-border) bg-(--clarify-code-header-background) px-2.5 text-sm font-medium",
|
|
3999
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
4000
|
+
className: "mr-auto text-(--clarify-code-text)",
|
|
4001
|
+
children: t("openapi.response")
|
|
4002
|
+
}), exchange ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
4003
|
+
/* @__PURE__ */ jsxs("span", {
|
|
4004
|
+
className: "text-xs font-semibold text-(--clarify-code-muted)",
|
|
4005
|
+
children: [exchange.duration, " ms"]
|
|
4006
|
+
}),
|
|
4007
|
+
/* @__PURE__ */ jsx("span", {
|
|
4008
|
+
className: "text-xs text-(--clarify-code-faint)",
|
|
4009
|
+
children: formatBytes(exchange.size)
|
|
4010
|
+
}),
|
|
4011
|
+
/* @__PURE__ */ jsx("span", { className: clsx("size-2 rounded-full", exchange.status < 400 ? "bg-(--clarify-code-success)" : "bg-(--clarify-code-danger)") }),
|
|
4012
|
+
/* @__PURE__ */ jsxs("span", {
|
|
4013
|
+
className: clsx("text-xs font-semibold", exchange.status < 400 ? "text-(--clarify-code-success)" : "text-(--clarify-code-danger)"),
|
|
4014
|
+
children: [
|
|
4015
|
+
exchange.status,
|
|
4016
|
+
" ",
|
|
4017
|
+
exchange.statusText
|
|
4018
|
+
]
|
|
4019
|
+
})
|
|
4020
|
+
] }) : null]
|
|
4021
|
+
}),
|
|
4022
|
+
error ? /* @__PURE__ */ jsx(ResponseState, {
|
|
4023
|
+
icon: CircleAlertIcon,
|
|
4024
|
+
title: t("openapi.responseErrorTitle"),
|
|
4025
|
+
description: error,
|
|
4026
|
+
tone: "error"
|
|
4027
|
+
}) : null,
|
|
4028
|
+
!error && !exchange ? /* @__PURE__ */ jsx(ResponseState, {
|
|
4029
|
+
icon: SendIcon,
|
|
4030
|
+
title: t("openapi.responseEmptyTitle"),
|
|
4031
|
+
description: t("openapi.responseEmpty")
|
|
4032
|
+
}) : null,
|
|
4033
|
+
exchange ? /* @__PURE__ */ jsxs("div", {
|
|
4034
|
+
className: "min-h-0 flex-1 overflow-auto",
|
|
4035
|
+
children: [
|
|
4036
|
+
/* @__PURE__ */ jsx(RequestSection, {
|
|
4037
|
+
title: t("openapi.cookies"),
|
|
4038
|
+
count: 0,
|
|
4039
|
+
children: /* @__PURE__ */ jsx(HiddenCookies, {})
|
|
4040
|
+
}),
|
|
4041
|
+
/* @__PURE__ */ jsx(RequestSection, {
|
|
4042
|
+
title: t("openapi.requestHeaders"),
|
|
4043
|
+
count: exchange.request.headers.length,
|
|
4044
|
+
children: /* @__PURE__ */ jsx(ResponseHeaders, { headers: exchange.request.headers })
|
|
4045
|
+
}),
|
|
4046
|
+
/* @__PURE__ */ jsx(RequestSection, {
|
|
4047
|
+
title: t("openapi.responseHeaders"),
|
|
4048
|
+
count: exchange.headers.length,
|
|
4049
|
+
children: /* @__PURE__ */ jsx(ResponseHeaders, { headers: exchange.headers })
|
|
4050
|
+
}),
|
|
4051
|
+
/* @__PURE__ */ jsx(RequestSection, {
|
|
4052
|
+
title: t("openapi.body"),
|
|
4053
|
+
defaultOpen: true,
|
|
4054
|
+
actions: /* @__PURE__ */ jsx("span", {
|
|
4055
|
+
className: "font-mono text-2xs font-normal text-(--clarify-code-faint)",
|
|
4056
|
+
children: exchange.contentType || t("openapi.unknownContentType")
|
|
4057
|
+
}),
|
|
4058
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
4059
|
+
className: "min-h-72",
|
|
4060
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
4061
|
+
className: "flex h-10 items-center justify-between border-b border-(--clarify-code-border) px-3",
|
|
4062
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
4063
|
+
role: "tablist",
|
|
4064
|
+
className: "flex",
|
|
4065
|
+
children: ["preview", "raw"].map((mode) => /* @__PURE__ */ jsx("button", {
|
|
4066
|
+
type: "button",
|
|
4067
|
+
role: "tab",
|
|
4068
|
+
"aria-selected": bodyMode === mode,
|
|
4069
|
+
onClick: () => setBodyMode(mode),
|
|
4070
|
+
className: clsx("border-b-2 px-2.5 py-1 text-2xs font-semibold", bodyMode === mode ? "border-(--clarify-theme-tokens-colors-primary) text-(--clarify-code-text)" : "border-transparent text-(--clarify-code-muted)"),
|
|
4071
|
+
children: mode === "preview" ? t("openapi.preview") : t("openapi.raw")
|
|
4072
|
+
}, mode))
|
|
4073
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
4074
|
+
className: "flex",
|
|
4075
|
+
children: [/* @__PURE__ */ jsx(CopyButton, { value: exchange.body }), /* @__PURE__ */ jsx("button", {
|
|
4076
|
+
type: "button",
|
|
4077
|
+
onClick: downloadBody,
|
|
4078
|
+
"aria-label": t("openapi.downloadBody"),
|
|
4079
|
+
title: t("openapi.downloadBody"),
|
|
4080
|
+
className: "grid size-8 shrink-0 place-items-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-code-muted) transition hover:bg-(--clarify-code-control-background-hover) hover:text-(--clarify-code-text) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
|
|
4081
|
+
children: /* @__PURE__ */ jsx(DownloadIcon, {
|
|
4082
|
+
className: "size-4",
|
|
4083
|
+
"aria-hidden": "true"
|
|
4084
|
+
})
|
|
4085
|
+
})]
|
|
4086
|
+
})]
|
|
4087
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
4088
|
+
className: "p-4",
|
|
4089
|
+
children: bodyMode === "preview" ? /* @__PURE__ */ jsx(ResponsePreview, { exchange }) : exchange.size ? /* @__PURE__ */ jsx("pre", {
|
|
4090
|
+
className: "max-h-128 overflow-auto whitespace-pre-wrap wrap-break-word font-mono text-xs/5",
|
|
4091
|
+
children: exchange.body
|
|
4092
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
4093
|
+
className: "py-8 text-center text-xs text-(--clarify-code-faint)",
|
|
4094
|
+
children: t("openapi.responseBodyEmpty")
|
|
4095
|
+
})
|
|
4096
|
+
})]
|
|
4097
|
+
})
|
|
4098
|
+
})
|
|
4099
|
+
]
|
|
4100
|
+
}) : null
|
|
4101
|
+
]
|
|
4102
|
+
});
|
|
4103
|
+
}
|
|
4104
|
+
//#endregion
|
|
4105
|
+
//#region source/openapi/components/SendRequestButton.tsx
|
|
4106
|
+
function SendRequestButton(arg0) {
|
|
4107
|
+
const { label, busy = false, text, onClick } = arg0;
|
|
4108
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
4109
|
+
type: "button",
|
|
4110
|
+
disabled: busy,
|
|
4111
|
+
"aria-label": label,
|
|
4112
|
+
title: label,
|
|
4113
|
+
onClick,
|
|
4114
|
+
className: Boolean(text) ? "flex h-8 shrink-0 items-center gap-1.5 rounded bg-(--clarify-theme-tokens-colors-foreground) px-3 text-xs font-semibold text-(--clarify-theme-tokens-colors-background) transition hover:opacity-85 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-foreground) focus-visible:ring-offset-2 disabled:cursor-wait disabled:opacity-60" : "grid size-7 shrink-0 place-items-center rounded bg-(--clarify-ui-accent-background) text-(--clarify-ui-accent-text) ring-1 ring-inset ring-(--clarify-ui-accent-border) transition-colors hover:bg-(--clarify-theme-tokens-colors-foreground) hover:text-(--clarify-theme-tokens-colors-background) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-foreground) focus-visible:ring-offset-2 disabled:cursor-wait disabled:opacity-60",
|
|
4115
|
+
children: [busy ? /* @__PURE__ */ jsx(LoaderCircleIcon, {
|
|
4116
|
+
className: "size-4 animate-spin",
|
|
4117
|
+
"aria-hidden": "true"
|
|
4118
|
+
}) : /* @__PURE__ */ jsx(SendIcon, {
|
|
4119
|
+
className: "size-4",
|
|
4120
|
+
"aria-hidden": "true"
|
|
4121
|
+
}), text]
|
|
4122
|
+
});
|
|
4123
|
+
}
|
|
4124
|
+
//#endregion
|
|
4125
|
+
//#region source/openapi/lib/api-exchange.ts
|
|
4126
|
+
var ApiRequestError = class extends Error {
|
|
4127
|
+
category;
|
|
4128
|
+
constructor(message, options) {
|
|
4129
|
+
super(message, options);
|
|
4130
|
+
this.name = "ApiRequestError";
|
|
4131
|
+
this.category = "network";
|
|
4132
|
+
}
|
|
4133
|
+
};
|
|
4134
|
+
function requestBodySnapshot(body) {
|
|
4135
|
+
if (typeof body === "string") return body;
|
|
4136
|
+
if (body instanceof URLSearchParams) return body.toString();
|
|
4137
|
+
}
|
|
4138
|
+
function requestSnapshot(request) {
|
|
4139
|
+
return {
|
|
4140
|
+
url: request.url,
|
|
4141
|
+
method: request.init.method ?? "GET",
|
|
4142
|
+
headers: Array.from(new Headers(request.init.headers).entries()),
|
|
4143
|
+
body: requestBodySnapshot(request.init.body)
|
|
4144
|
+
};
|
|
4145
|
+
}
|
|
4146
|
+
async function executeApiRequest(request, options = {}) {
|
|
4147
|
+
const fetchRequest = options.fetch ?? fetch;
|
|
4148
|
+
const now = options.now ?? (() => performance.now());
|
|
4149
|
+
const startedAt = now();
|
|
4150
|
+
let response;
|
|
4151
|
+
try {
|
|
4152
|
+
response = await fetchRequest(request.url, {
|
|
4153
|
+
...request.init,
|
|
4154
|
+
signal: options.signal
|
|
4155
|
+
});
|
|
4156
|
+
} catch (cause) {
|
|
4157
|
+
if (cause instanceof DOMException && cause.name === "AbortError") throw cause;
|
|
4158
|
+
throw new ApiRequestError(cause instanceof Error ? cause.message : String(cause), { cause });
|
|
4159
|
+
}
|
|
4160
|
+
const blob = await response.blob();
|
|
4161
|
+
return {
|
|
4162
|
+
request: requestSnapshot(request),
|
|
4163
|
+
status: response.status,
|
|
4164
|
+
statusText: response.statusText,
|
|
4165
|
+
url: response.url || request.url,
|
|
4166
|
+
redirected: response.redirected,
|
|
4167
|
+
duration: Math.round(now() - startedAt),
|
|
4168
|
+
size: blob.size,
|
|
4169
|
+
headers: Array.from(response.headers.entries()),
|
|
4170
|
+
contentType: response.headers.get("content-type") ?? blob.type,
|
|
4171
|
+
body: await blob.text(),
|
|
4172
|
+
blob
|
|
4173
|
+
};
|
|
4174
|
+
}
|
|
4175
|
+
//#endregion
|
|
4176
|
+
//#region source/openapi/lib/request-parameters.ts
|
|
4177
|
+
function structuredIssue(value, type) {
|
|
4178
|
+
if (!type.includes("[]") && !type.includes("object")) return void 0;
|
|
4179
|
+
try {
|
|
4180
|
+
const parsed = JSON.parse(value);
|
|
4181
|
+
if (type.includes("[]") && !Array.isArray(parsed)) return "invalidArray";
|
|
4182
|
+
if (type.includes("object") && !isRecord$1(parsed)) return "invalidObject";
|
|
4183
|
+
} catch {
|
|
4184
|
+
return type.includes("[]") ? "invalidArray" : "invalidObject";
|
|
4185
|
+
}
|
|
4186
|
+
}
|
|
4187
|
+
function scalarIssue(value, type, format) {
|
|
4188
|
+
if (type.includes("integer") && !Number.isInteger(Number(value))) return "invalidInteger";
|
|
4189
|
+
if (type.includes("number") && !Number.isFinite(Number(value))) return "invalidNumber";
|
|
4190
|
+
if (format === "date" && !/^\d{4}-\d{2}-\d{2}$/.test(value)) return "invalidDate";
|
|
4191
|
+
if (format === "date-time" && Number.isNaN(Date.parse(value))) return "invalidDateTime";
|
|
4192
|
+
}
|
|
4193
|
+
function validateRequestParameter(spec, parameter, value) {
|
|
4194
|
+
if (!value) return parameter.required ? "required" : void 0;
|
|
4195
|
+
const schema = resolveSchema(spec, parameter.schema);
|
|
4196
|
+
const schemaRecord = isRecord$1(schema) ? schema : void 0;
|
|
4197
|
+
const type = schemaToType(schema) ?? "string";
|
|
4198
|
+
const options = Array.isArray(schemaRecord?.enum) ? schemaRecord.enum.map(String) : [];
|
|
4199
|
+
if (options.length > 0 && !options.includes(value)) return "invalidEnum";
|
|
4200
|
+
return structuredIssue(value, type) ?? scalarIssue(value, type, schemaRecord?.format);
|
|
4201
|
+
}
|
|
4202
|
+
function validateRequestParameters(spec, parameters, values) {
|
|
4203
|
+
return Object.fromEntries(parameters.filter((parameter) => parameter.in !== "cookie").flatMap((parameter) => {
|
|
4204
|
+
const key = parameterKey(parameter);
|
|
4205
|
+
const issue = validateRequestParameter(spec, parameter, values[key] ?? "");
|
|
4206
|
+
return issue ? [[key, issue]] : [];
|
|
4207
|
+
}));
|
|
4208
|
+
}
|
|
4209
|
+
//#endregion
|
|
4210
|
+
//#region source/openapi/components/useOpenApiRequestState.ts
|
|
4211
|
+
function useOpenApiRequestTarget(spec, path, operation, operationSource) {
|
|
4212
|
+
const servers = getServers(spec, operation, path, operationSource);
|
|
4213
|
+
const [selectedServerKey, setSelectedServerKey] = useState(getServerKey(servers[0], 0));
|
|
4214
|
+
const selectedServer = servers.find((server, index) => getServerKey(server, index) === selectedServerKey) ?? servers[0];
|
|
4215
|
+
const [serverVariables, setServerVariables] = useState(defaultServerVariables(selectedServer));
|
|
4216
|
+
const authOptions = getAuthOptions(spec, operation);
|
|
4217
|
+
const [selectedAuthName, setSelectedAuthName] = useState(authOptions[0]?.key ?? "");
|
|
4218
|
+
const selectedAuth = authOptions.find((option) => option.key === selectedAuthName);
|
|
4219
|
+
const credentialScope = getOpenApiCredentialScope(spec);
|
|
4220
|
+
const credentials = useOpenApiStore((state) => state.credentials[credentialScope] ?? emptyOpenApiCredentials);
|
|
4221
|
+
const setCredential = useOpenApiStore((state) => state.setCredential);
|
|
4222
|
+
const clearCredential = useOpenApiStore((state) => state.clearCredential);
|
|
4223
|
+
const requestContents = getMediaTypeEntries(getRequestBody$1(spec, operation)?.content, spec);
|
|
4224
|
+
const [mediaType, setMediaType] = useState(requestContents[0]?.mediaType ?? "");
|
|
4225
|
+
const [body, setBody] = useState(stringifyExample(getExampleEntries((requestContents.find((entry) => entry.mediaType === mediaType) ?? requestContents[0])?.value, spec)[0]?.value));
|
|
4226
|
+
function selectServer(value) {
|
|
4227
|
+
const nextServer = servers.find((server, index) => getServerKey(server, index) === value) ?? servers[0];
|
|
4228
|
+
setSelectedServerKey(value);
|
|
4229
|
+
setServerVariables(defaultServerVariables(nextServer));
|
|
4230
|
+
}
|
|
4231
|
+
function selectMediaType(value) {
|
|
4232
|
+
const content = requestContents.find((entry) => entry.mediaType === value)?.value;
|
|
4233
|
+
setMediaType(value);
|
|
4234
|
+
setBody(stringifyExample(getExampleEntries(content, spec)[0]?.value));
|
|
4235
|
+
}
|
|
4236
|
+
return {
|
|
4237
|
+
servers,
|
|
4238
|
+
selectedServer,
|
|
4239
|
+
selectedServerKey,
|
|
4240
|
+
serverVariables,
|
|
4241
|
+
setServerVariables,
|
|
4242
|
+
serverVariableEntries: Object.entries(selectedServer.variables ?? {}),
|
|
4243
|
+
selectServer,
|
|
4244
|
+
authOptions,
|
|
4245
|
+
selectedAuthName,
|
|
4246
|
+
setSelectedAuthName,
|
|
4247
|
+
selectedAuth,
|
|
4248
|
+
credentialScope,
|
|
4249
|
+
credentials,
|
|
4250
|
+
setCredential,
|
|
4251
|
+
clearCredential,
|
|
4252
|
+
requestContents,
|
|
4253
|
+
mediaType,
|
|
4254
|
+
body,
|
|
4255
|
+
setBody,
|
|
4256
|
+
selectMediaType
|
|
4257
|
+
};
|
|
4258
|
+
}
|
|
4259
|
+
function useOpenApiParameterState(spec, parameters, initialParameterValue) {
|
|
4260
|
+
const [parameterValues, setParameterValues] = useState(() => Object.fromEntries(parameters.map((parameter) => [parameterKey(parameter), initialParameterValue(parameter)])));
|
|
4261
|
+
const [parameterEnabled, setParameterEnabled] = useState(() => Object.fromEntries(parameters.map((parameter) => [parameterKey(parameter), true])));
|
|
4262
|
+
const [parameterIssues, setParameterIssues] = useState({});
|
|
4263
|
+
function setParameterGroupValues(grouped, mode) {
|
|
4264
|
+
const keys = new Set(grouped.map(parameterKey));
|
|
4265
|
+
setParameterValues((current) => ({
|
|
4266
|
+
...current,
|
|
4267
|
+
...Object.fromEntries(grouped.map((parameter) => [parameterKey(parameter), mode === "reset" ? initialParameterValue(parameter) : ""]))
|
|
4268
|
+
}));
|
|
4269
|
+
setParameterIssues((current) => Object.fromEntries(Object.entries(current).filter(([key]) => !keys.has(key))));
|
|
4270
|
+
}
|
|
4271
|
+
function setParameterIncluded(parameter, enabled) {
|
|
4272
|
+
const key = parameterKey(parameter);
|
|
4273
|
+
setParameterEnabled((current) => ({
|
|
4274
|
+
...current,
|
|
4275
|
+
[key]: enabled
|
|
4276
|
+
}));
|
|
4277
|
+
if (!enabled) setParameterIssues((current) => {
|
|
4278
|
+
const next = { ...current };
|
|
4279
|
+
delete next[key];
|
|
4280
|
+
return next;
|
|
4281
|
+
});
|
|
4282
|
+
}
|
|
4283
|
+
function updateParameterValue(parameter, value) {
|
|
4284
|
+
const key = parameterKey(parameter);
|
|
4285
|
+
setParameterValues((current) => ({
|
|
4286
|
+
...current,
|
|
4287
|
+
[key]: value
|
|
4288
|
+
}));
|
|
4289
|
+
setParameterIssues((current) => {
|
|
4290
|
+
const next = { ...current };
|
|
4291
|
+
delete next[key];
|
|
4292
|
+
return next;
|
|
4293
|
+
});
|
|
4294
|
+
}
|
|
4295
|
+
function validate(parametersToValidate) {
|
|
4296
|
+
const issues = validateRequestParameters(spec, parametersToValidate, parameterValues);
|
|
4297
|
+
setParameterIssues(issues);
|
|
4298
|
+
return issues;
|
|
4299
|
+
}
|
|
4300
|
+
return {
|
|
4301
|
+
parameterValues,
|
|
4302
|
+
parameterEnabled,
|
|
4303
|
+
parameterIssues,
|
|
4304
|
+
setParameterGroupValues,
|
|
4305
|
+
setParameterIncluded,
|
|
4306
|
+
updateParameterValue,
|
|
4307
|
+
validate
|
|
4308
|
+
};
|
|
4309
|
+
}
|
|
4310
|
+
function useOpenApiRequestExecution() {
|
|
4311
|
+
const [exchange, setExchange] = useState();
|
|
4312
|
+
const [error, setError] = useState("");
|
|
4313
|
+
const [sending, setSending] = useState(false);
|
|
4314
|
+
const requestController = useRef(null);
|
|
4315
|
+
useEffect(() => () => requestController.current?.abort(), []);
|
|
4316
|
+
async function execute(request, corsHint) {
|
|
4317
|
+
requestController.current?.abort();
|
|
4318
|
+
const controller = new AbortController();
|
|
4319
|
+
requestController.current = controller;
|
|
4320
|
+
setSending(true);
|
|
4321
|
+
setError("");
|
|
4322
|
+
setExchange(void 0);
|
|
4323
|
+
try {
|
|
4324
|
+
setExchange(await executeApiRequest(request, { signal: controller.signal }));
|
|
4325
|
+
} catch (cause) {
|
|
4326
|
+
if (cause instanceof DOMException && cause.name === "AbortError") return;
|
|
4327
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
4328
|
+
setError(`${message}. ${corsHint}`);
|
|
4329
|
+
} finally {
|
|
4330
|
+
if (requestController.current === controller) {
|
|
4331
|
+
requestController.current = null;
|
|
4332
|
+
setSending(false);
|
|
4333
|
+
}
|
|
4334
|
+
}
|
|
4335
|
+
}
|
|
4336
|
+
return {
|
|
4337
|
+
exchange,
|
|
4338
|
+
error,
|
|
4339
|
+
sending,
|
|
4340
|
+
execute
|
|
4341
|
+
};
|
|
4342
|
+
}
|
|
4343
|
+
//#endregion
|
|
4344
|
+
//#region source/openapi/components/OpenApiRequest.tsx
|
|
4345
|
+
function initialParameterValue(spec, parameter) {
|
|
4346
|
+
const schema = resolveSchema(spec, parameter.schema);
|
|
4347
|
+
if (!isRecord$1(schema)) return "";
|
|
4348
|
+
return stringifyExample(schema.example ?? schema.default ?? (Array.isArray(schema.enum) ? schema.enum[0] : void 0));
|
|
4349
|
+
}
|
|
4350
|
+
function parameterGroupLabel(location, t) {
|
|
4351
|
+
if (location === "path") return t("openapi.pathParameters");
|
|
4352
|
+
if (location === "header") return t("openapi.headers");
|
|
4353
|
+
if (location === "cookie") return t("openapi.cookies");
|
|
4354
|
+
return t("openapi.queryParameters");
|
|
4355
|
+
}
|
|
4356
|
+
function OpenApiRequestWorkbench(arg0) {
|
|
4357
|
+
const { spec, path, method, operation, operationSource = "path", compact = false, onClose } = arg0;
|
|
4358
|
+
const t = useBuiltInText();
|
|
4359
|
+
const parameters = getOperationParameters(spec, path, operation, operationSource);
|
|
4360
|
+
const { servers, selectedServer, selectedServerKey, serverVariables, setServerVariables, serverVariableEntries, selectServer, authOptions, selectedAuthName, setSelectedAuthName, selectedAuth, credentialScope, credentials, setCredential, clearCredential, requestContents, mediaType, body, setBody, selectMediaType } = useOpenApiRequestTarget(spec, path, operation, operationSource);
|
|
4361
|
+
const parameterState = useOpenApiParameterState(spec, parameters, (parameter) => initialParameterValue(spec, parameter));
|
|
4362
|
+
const { parameterValues, parameterEnabled, parameterIssues, setParameterGroupValues, setParameterIncluded, updateParameterValue } = parameterState;
|
|
4363
|
+
const { exchange, error, sending, execute } = useOpenApiRequestExecution();
|
|
4364
|
+
const parameterGroups = [
|
|
4365
|
+
"cookie",
|
|
4366
|
+
"header",
|
|
4367
|
+
"query"
|
|
4368
|
+
].map((location) => ({
|
|
4369
|
+
location,
|
|
4370
|
+
parameters: parameters.filter((parameter) => parameter.in === location)
|
|
4371
|
+
})).filter((group) => group.parameters.length > 0);
|
|
4372
|
+
const pathParameters = parameters.filter((parameter) => parameter.in === "path");
|
|
4373
|
+
const hasRequestConfiguration = authOptions.length > 0 || serverVariableEntries.length > 0 || parameters.length > 0 || requestContents.length > 0;
|
|
4374
|
+
async function sendRequest() {
|
|
4375
|
+
const enabledParameters = parameters.filter((parameter) => parameterEnabled[parameterKey(parameter)] !== false);
|
|
4376
|
+
const issues = parameterState.validate(enabledParameters);
|
|
4377
|
+
if (Object.keys(issues).length > 0) return;
|
|
4378
|
+
await execute(buildApiRequest({
|
|
4379
|
+
method,
|
|
4380
|
+
path,
|
|
4381
|
+
server: selectedServer,
|
|
4382
|
+
serverVariables,
|
|
4383
|
+
parameters,
|
|
4384
|
+
parameterValues,
|
|
4385
|
+
parameterEnabled,
|
|
4386
|
+
auth: selectedAuth?.schemes.map((option) => ({
|
|
4387
|
+
scheme: option.scheme,
|
|
4388
|
+
value: credentials[option.name] ?? ""
|
|
4389
|
+
})),
|
|
4390
|
+
mediaType,
|
|
4391
|
+
body,
|
|
4392
|
+
baseUrl: window.location.href
|
|
4393
|
+
}), t("openapi.requestCorsHint"));
|
|
4394
|
+
}
|
|
4395
|
+
function renderParameterField(parameter) {
|
|
4396
|
+
const key = parameterKey(parameter);
|
|
4397
|
+
return /* @__PURE__ */ jsx(RequestField, {
|
|
4398
|
+
spec,
|
|
4399
|
+
parameter,
|
|
4400
|
+
value: parameterValues[key] ?? "",
|
|
4401
|
+
enabled: parameterEnabled[key] !== false,
|
|
4402
|
+
issue: parameterIssues[key],
|
|
4403
|
+
onEnabledChange: (enabled) => setParameterIncluded(parameter, enabled),
|
|
4404
|
+
onChange: (value) => updateParameterValue(parameter, value)
|
|
4405
|
+
}, key);
|
|
4406
|
+
}
|
|
4407
|
+
function renderParameterGroup(group) {
|
|
4408
|
+
const { location, parameters: grouped } = group;
|
|
4409
|
+
const actions = location === "cookie" ? void 0 : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("button", {
|
|
4410
|
+
type: "button",
|
|
4411
|
+
title: t("openapi.resetToExample"),
|
|
4412
|
+
"aria-label": t("openapi.resetToExample"),
|
|
4413
|
+
onClick: () => setParameterGroupValues(grouped, "reset"),
|
|
4414
|
+
className: "grid size-7 place-items-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-ui-text-faint) hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-ui-text-strong) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
|
|
4415
|
+
children: /* @__PURE__ */ jsx(RotateCcwIcon, {
|
|
4416
|
+
className: "size-3.5",
|
|
4417
|
+
"aria-hidden": "true"
|
|
4418
|
+
})
|
|
4419
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
4420
|
+
type: "button",
|
|
4421
|
+
title: t("openapi.clear"),
|
|
4422
|
+
"aria-label": t("openapi.clear"),
|
|
4423
|
+
onClick: () => setParameterGroupValues(grouped, "clear"),
|
|
4424
|
+
className: "grid size-7 place-items-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-ui-text-faint) hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-ui-text-strong) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
|
|
4425
|
+
children: /* @__PURE__ */ jsx(EraserIcon, {
|
|
4426
|
+
className: "size-3.5",
|
|
4427
|
+
"aria-hidden": "true"
|
|
4428
|
+
})
|
|
4429
|
+
})] });
|
|
4430
|
+
return /* @__PURE__ */ jsx(RequestSection, {
|
|
4431
|
+
title: parameterGroupLabel(location, t),
|
|
4432
|
+
count: grouped.length,
|
|
4433
|
+
defaultOpen: true,
|
|
4434
|
+
actions,
|
|
4435
|
+
children: location === "cookie" ? /* @__PURE__ */ jsx("p", {
|
|
4436
|
+
className: "px-3 py-4 text-xs/5 text-(--clarify-ui-text-faint)",
|
|
4437
|
+
children: t("openapi.cookieParametersBrowserManaged")
|
|
4438
|
+
}) : grouped.map(renderParameterField)
|
|
4439
|
+
}, location);
|
|
4440
|
+
}
|
|
4441
|
+
function renderHeader() {
|
|
4442
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
4443
|
+
className: "flex min-w-0 items-center gap-1.5 border-b border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) px-2.5 py-2",
|
|
4444
|
+
children: [
|
|
4445
|
+
/* @__PURE__ */ jsx(EndpointMethodBadge, { method: method.toUpperCase() }),
|
|
4446
|
+
servers.length > 0 ? /* @__PURE__ */ jsx(InlineListbox, {
|
|
4447
|
+
label: t("openapi.server"),
|
|
4448
|
+
value: selectedServerKey,
|
|
4449
|
+
options: servers.map((server, index) => ({
|
|
4450
|
+
value: getServerKey(server, index),
|
|
4451
|
+
label: server.url ?? `Server ${index + 1}`,
|
|
4452
|
+
description: server.description
|
|
4453
|
+
})),
|
|
4454
|
+
onChange: selectServer,
|
|
4455
|
+
className: "min-w-0 max-w-48 shrink sm:max-w-48",
|
|
4456
|
+
buttonClassName: "flex h-8 min-w-0 max-w-full items-center gap-1 rounded-(--clarify-theme-tokens-radius-md) px-2 text-xs font-medium text-(--clarify-ui-text-strong) outline-hidden transition hover:bg-(--clarify-ui-hover-background) focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-(--clarify-theme-tokens-colors-primary)"
|
|
4457
|
+
}) : null,
|
|
4458
|
+
/* @__PURE__ */ jsx("span", {
|
|
4459
|
+
className: "min-w-0 flex-1 overflow-x-auto border-l border-(--clarify-theme-tokens-colors-border) pl-2 font-mono text-xs text-(--clarify-theme-tokens-colors-foreground)",
|
|
4460
|
+
children: path || "/"
|
|
4461
|
+
}),
|
|
4462
|
+
/* @__PURE__ */ jsx(SendRequestButton, {
|
|
4463
|
+
label: sending ? t("openapi.sendingRequest") : t("openapi.sendRequest"),
|
|
4464
|
+
busy: sending,
|
|
4465
|
+
text: t("openapi.sendRequest"),
|
|
4466
|
+
onClick: sendRequest
|
|
4467
|
+
}),
|
|
4468
|
+
onClose ? /* @__PURE__ */ jsx("button", {
|
|
4469
|
+
type: "button",
|
|
4470
|
+
onClick: onClose,
|
|
4471
|
+
"aria-label": t("openapi.closeRequest"),
|
|
4472
|
+
title: t("openapi.closeRequest"),
|
|
4473
|
+
className: "grid size-8 shrink-0 place-items-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-ui-text-soft) 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)",
|
|
4474
|
+
children: /* @__PURE__ */ jsx(XIcon, {
|
|
4475
|
+
className: "size-4",
|
|
2980
4476
|
"aria-hidden": "true"
|
|
2981
|
-
})
|
|
2982
|
-
}
|
|
4477
|
+
})
|
|
4478
|
+
}) : null
|
|
4479
|
+
]
|
|
4480
|
+
});
|
|
4481
|
+
}
|
|
4482
|
+
function renderVariables() {
|
|
4483
|
+
if (serverVariableEntries.length === 0) return null;
|
|
4484
|
+
return /* @__PURE__ */ jsx(RequestSection, {
|
|
4485
|
+
title: t("openapi.variables"),
|
|
4486
|
+
count: serverVariableEntries.length,
|
|
4487
|
+
defaultOpen: true,
|
|
4488
|
+
children: serverVariableEntries.map(([name, variable]) => /* @__PURE__ */ jsxs("label", {
|
|
4489
|
+
className: "grid min-w-0 grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",
|
|
4490
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
4491
|
+
className: "flex min-h-8 items-center border-r border-(--clarify-theme-tokens-colors-border) px-2 font-mono text-xs text-(--clarify-ui-text-strong)",
|
|
4492
|
+
children: name
|
|
4493
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
4494
|
+
value: serverVariables[name] ?? variable.default ?? "",
|
|
4495
|
+
onChange: (event) => setServerVariables((current) => ({
|
|
4496
|
+
...current,
|
|
4497
|
+
[name]: event.target.value
|
|
4498
|
+
})),
|
|
4499
|
+
className: "h-8 min-w-0 border-0 bg-transparent px-2 font-mono text-xs text-(--clarify-theme-tokens-colors-foreground) outline-hidden focus:bg-(--clarify-ui-hover-background) focus:ring-0"
|
|
4500
|
+
})]
|
|
4501
|
+
}, name))
|
|
4502
|
+
});
|
|
4503
|
+
}
|
|
4504
|
+
function renderRequestBody() {
|
|
4505
|
+
if (requestContents.length === 0) return null;
|
|
4506
|
+
return /* @__PURE__ */ jsxs(RequestSection, {
|
|
4507
|
+
title: t("openapi.requestBody"),
|
|
4508
|
+
count: 1,
|
|
4509
|
+
defaultOpen: true,
|
|
4510
|
+
className: "open:grid open:min-h-55 open:grow open:shrink open:basis-55 open:grid-rows-[auto_minmax(11rem,1fr)]",
|
|
4511
|
+
contentClassName: clsx("grid h-full min-h-0", requestContents.length > 1 ? "grid-rows-[auto_minmax(11rem,1fr)]" : "grid-rows-[minmax(11rem,1fr)]"),
|
|
4512
|
+
children: [requestContents.length > 1 ? /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(InlineListbox, {
|
|
4513
|
+
label: t("openapi.mediaType"),
|
|
4514
|
+
value: mediaType,
|
|
4515
|
+
options: requestContents.map((entry) => ({
|
|
4516
|
+
value: entry.mediaType,
|
|
4517
|
+
label: entry.mediaType
|
|
4518
|
+
})),
|
|
4519
|
+
onChange: selectMediaType
|
|
4520
|
+
}) }) : null, /* @__PURE__ */ jsx("textarea", {
|
|
4521
|
+
"aria-label": t("openapi.requestBody"),
|
|
4522
|
+
value: body,
|
|
4523
|
+
onChange: (event) => setBody(event.target.value),
|
|
4524
|
+
spellCheck: false,
|
|
4525
|
+
className: "block h-full min-h-44 w-full resize-none border-0 bg-(--clarify-code-background) p-3 font-mono text-xs/5 text-(--clarify-code-text) outline-hidden focus:ring-2 focus:ring-inset focus:ring-(--clarify-theme-tokens-colors-primary)"
|
|
2983
4526
|
})]
|
|
2984
|
-
})
|
|
4527
|
+
});
|
|
4528
|
+
}
|
|
4529
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
4530
|
+
className: clsx("clarify-api-request flex min-h-0 min-w-0 flex-col not-prose bg-(--clarify-theme-tokens-colors-surface) [--clarify-theme-tokens-radius-lg:6px] [--clarify-theme-tokens-radius-md:4px] [--clarify-theme-tokens-radius-sm:2px] [--clarify-theme-tokens-radius-xl:8px] [--clarify-ui-accent-background:color-mix(in_srgb,var(--clarify-theme-tokens-colors-foreground)_10%,transparent)] [--clarify-ui-accent-border:color-mix(in_srgb,var(--clarify-theme-tokens-colors-foreground)_22%,transparent)] [--clarify-ui-accent-text:var(--clarify-theme-tokens-colors-foreground)] [--clarify-ui-active-background:color-mix(in_srgb,var(--clarify-theme-tokens-colors-foreground)_12%,transparent)] [--clarify-ui-subtle-background:color-mix(in_srgb,var(--clarify-theme-tokens-colors-foreground)_5%,transparent)]", compact ? "h-full" : "my-6"),
|
|
4531
|
+
children: [renderHeader(), /* @__PURE__ */ jsxs("div", {
|
|
4532
|
+
className: "grid min-h-0 flex-1 gap-0 px-0 lg:grid-cols-[minmax(0,1.12fr)_minmax(22rem,0.88fr)]",
|
|
4533
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
4534
|
+
className: "flex min-h-0 min-w-0 flex-col overflow-y-auto",
|
|
4535
|
+
children: [
|
|
4536
|
+
authOptions.length > 0 ? /* @__PURE__ */ jsx(RequestSection, {
|
|
4537
|
+
title: t("openapi.authentication"),
|
|
4538
|
+
count: selectedAuth?.schemes.length ?? 0,
|
|
4539
|
+
defaultOpen: true,
|
|
4540
|
+
children: /* @__PURE__ */ jsx(OpenApiAuthPanel, {
|
|
4541
|
+
authOptions,
|
|
4542
|
+
selectedAuthName,
|
|
4543
|
+
selectedAuth,
|
|
4544
|
+
authValues: credentials,
|
|
4545
|
+
onSelectAuth: setSelectedAuthName,
|
|
4546
|
+
onChangeAuthValue: (name, value) => setCredential(credentialScope, name, value),
|
|
4547
|
+
onClearAuthValue: (name) => clearCredential(credentialScope, name)
|
|
4548
|
+
})
|
|
4549
|
+
}) : null,
|
|
4550
|
+
renderVariables(),
|
|
4551
|
+
pathParameters.length > 0 ? /* @__PURE__ */ jsx(RequestSection, {
|
|
4552
|
+
title: t("openapi.pathParameters"),
|
|
4553
|
+
count: pathParameters.length,
|
|
4554
|
+
defaultOpen: true,
|
|
4555
|
+
children: pathParameters.map(renderParameterField)
|
|
4556
|
+
}) : null,
|
|
4557
|
+
parameterGroups.map(renderParameterGroup),
|
|
4558
|
+
renderRequestBody(),
|
|
4559
|
+
!hasRequestConfiguration ? /* @__PURE__ */ jsx(RequestSection, {
|
|
4560
|
+
title: t("openapi.requestConfiguration"),
|
|
4561
|
+
count: 0,
|
|
4562
|
+
defaultOpen: true,
|
|
4563
|
+
children: /* @__PURE__ */ jsx("p", {
|
|
4564
|
+
className: "px-3 py-5 text-xs/5 text-(--clarify-ui-text-faint)",
|
|
4565
|
+
children: t("openapi.noRequestConfiguration")
|
|
4566
|
+
})
|
|
4567
|
+
}) : null
|
|
4568
|
+
]
|
|
4569
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
4570
|
+
className: "h-full min-h-0 min-w-0 overflow-hidden border-t border-(--clarify-theme-tokens-colors-border) lg:border-t-0 lg:border-l",
|
|
4571
|
+
children: /* @__PURE__ */ jsx(OpenApiResponseViewer, {
|
|
4572
|
+
exchange,
|
|
4573
|
+
error
|
|
4574
|
+
})
|
|
4575
|
+
})]
|
|
4576
|
+
})]
|
|
4577
|
+
});
|
|
4578
|
+
}
|
|
4579
|
+
function OpenApiRequestDialog(arg0) {
|
|
4580
|
+
const { open, onClose, ...workbenchProps } = arg0;
|
|
4581
|
+
const t = useBuiltInText();
|
|
4582
|
+
return /* @__PURE__ */ jsxs(Dialog, {
|
|
4583
|
+
open,
|
|
4584
|
+
onClose: () => {},
|
|
4585
|
+
className: "relative z-50",
|
|
4586
|
+
children: [/* @__PURE__ */ jsx(DialogBackdrop, { className: "fixed inset-0 bg-(--clarify-ui-overlay-background) backdrop-blur-sm" }), /* @__PURE__ */ jsx("div", {
|
|
4587
|
+
className: "fixed inset-0 grid place-items-center overflow-y-auto p-3 sm:p-6",
|
|
4588
|
+
children: /* @__PURE__ */ jsxs(DialogPanel, {
|
|
4589
|
+
className: "relative flex h-[min(46rem,calc(100dvh-1.5rem))] w-full max-w-7xl flex-col overflow-hidden rounded-lg border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-background) shadow-2xl sm:h-[min(46rem,calc(100dvh-3rem))]",
|
|
4590
|
+
children: [/* @__PURE__ */ jsx(DialogTitle, {
|
|
4591
|
+
className: "sr-only",
|
|
4592
|
+
children: t("openapi.tryRequest")
|
|
4593
|
+
}), /* @__PURE__ */ jsx(OpenApiRequestWorkbench, {
|
|
4594
|
+
...workbenchProps,
|
|
4595
|
+
compact: true,
|
|
4596
|
+
onClose
|
|
4597
|
+
})]
|
|
4598
|
+
})
|
|
4599
|
+
})]
|
|
4600
|
+
});
|
|
4601
|
+
}
|
|
4602
|
+
//#endregion
|
|
4603
|
+
//#region source/openapi/components/OpenApiOperation.tsx
|
|
4604
|
+
function EndpointPath(arg0) {
|
|
4605
|
+
const { path, copied = false, onCopy } = arg0;
|
|
4606
|
+
const t = useBuiltInText();
|
|
4607
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
4608
|
+
className: "flex min-w-0 flex-1 items-center gap-2 overflow-hidden",
|
|
4609
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
4610
|
+
className: "min-w-0 flex-1 overflow-x-auto text-sm font-bold leading-6 whitespace-nowrap",
|
|
4611
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
4612
|
+
className: "select-text font-mono text-(--clarify-theme-tokens-colors-foreground)",
|
|
4613
|
+
children: path || "/"
|
|
4614
|
+
})
|
|
4615
|
+
}), onCopy ? /* @__PURE__ */ jsx("button", {
|
|
4616
|
+
type: "button",
|
|
4617
|
+
"aria-label": copied ? t("actions.copied") : t("actions.copy"),
|
|
4618
|
+
title: copied ? t("actions.copied") : t("actions.copy"),
|
|
4619
|
+
onClick: onCopy,
|
|
4620
|
+
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"),
|
|
4621
|
+
children: copied ? /* @__PURE__ */ jsx(CheckIcon, {
|
|
4622
|
+
className: "h-3.5 w-3.5",
|
|
4623
|
+
"aria-hidden": "true"
|
|
4624
|
+
}) : /* @__PURE__ */ jsx(CopyIcon, {
|
|
4625
|
+
className: "h-3.5 w-3.5",
|
|
4626
|
+
"aria-hidden": "true"
|
|
4627
|
+
})
|
|
4628
|
+
}) : null]
|
|
2985
4629
|
});
|
|
2986
4630
|
}
|
|
2987
4631
|
function getServerPreviewUrl(server, variables) {
|
|
@@ -3007,7 +4651,7 @@ function getDefaultResponseStatus(operation, spec) {
|
|
|
3007
4651
|
return orderedResponses.find(({ status }) => status === "default")?.status ?? orderedResponses.find(({ status }) => status.startsWith("2"))?.status ?? orderedResponses[0]?.status ?? "";
|
|
3008
4652
|
}
|
|
3009
4653
|
function ServerUrlValue(arg0) {
|
|
3010
|
-
const { server, variables, open, interactive, onToggle } = arg0;
|
|
4654
|
+
const { servers, selectedKey, server, variables, open, interactive, directSelect, onSelect, onToggle } = arg0;
|
|
3011
4655
|
const url = getServerPreviewUrl(server, variables);
|
|
3012
4656
|
const protocolLabel = getServerProtocolLabel(server, variables);
|
|
3013
4657
|
if (!interactive) return /* @__PURE__ */ jsxs("span", {
|
|
@@ -3030,12 +4674,47 @@ function ServerUrlValue(arg0) {
|
|
|
3030
4674
|
})]
|
|
3031
4675
|
})]
|
|
3032
4676
|
});
|
|
4677
|
+
if (directSelect) return /* @__PURE__ */ jsx(InlineListbox, {
|
|
4678
|
+
label: "Server",
|
|
4679
|
+
value: selectedKey,
|
|
4680
|
+
options: servers.map((option, index) => ({
|
|
4681
|
+
value: getServerKey(option, index),
|
|
4682
|
+
label: getServerLabel(option, index),
|
|
4683
|
+
description: option.description
|
|
4684
|
+
})),
|
|
4685
|
+
onChange: onSelect,
|
|
4686
|
+
className: "w-8 shrink-0 sm:w-fit sm:min-w-16 sm:max-w-(--clarify-server-url-max-width)",
|
|
4687
|
+
buttonClassName: "group flex h-8 w-full min-w-0 cursor-pointer items-center justify-center rounded-lg bg-(--clarify-ui-subtle-background) px-0 text-(--clarify-ui-text) transition-colors 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) data-open:bg-(--clarify-ui-active-background) data-open:text-(--clarify-theme-tokens-colors-foreground) sm:px-1.5",
|
|
4688
|
+
buttonContent: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
|
|
4689
|
+
className: "sm:hidden",
|
|
4690
|
+
children: /* @__PURE__ */ jsx(ServerIcon, {
|
|
4691
|
+
className: "h-4 w-4",
|
|
4692
|
+
"aria-hidden": "true"
|
|
4693
|
+
})
|
|
4694
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
4695
|
+
className: "hidden min-w-0 items-center gap-1 overflow-hidden sm:flex",
|
|
4696
|
+
children: [
|
|
4697
|
+
protocolLabel ? /* @__PURE__ */ jsx("span", {
|
|
4698
|
+
className: "shrink-0 rounded bg-sky-100 px-1.5 py-0.5 text-2xs font-black text-sky-700 dark:bg-sky-400/15 dark:text-sky-200",
|
|
4699
|
+
children: protocolLabel
|
|
4700
|
+
}) : null,
|
|
4701
|
+
/* @__PURE__ */ jsx("span", {
|
|
4702
|
+
className: "truncate font-semibold text-xs",
|
|
4703
|
+
children: url
|
|
4704
|
+
}),
|
|
4705
|
+
/* @__PURE__ */ jsx(ChevronDownIcon, {
|
|
4706
|
+
className: "h-3.5 w-3.5 shrink-0 text-zinc-400 transition-transform group-data-open:rotate-180",
|
|
4707
|
+
"aria-hidden": "true"
|
|
4708
|
+
})
|
|
4709
|
+
]
|
|
4710
|
+
})] })
|
|
4711
|
+
});
|
|
3033
4712
|
return /* @__PURE__ */ jsxs("button", {
|
|
3034
4713
|
type: "button",
|
|
3035
4714
|
"aria-expanded": open,
|
|
3036
4715
|
"aria-label": "Server",
|
|
3037
4716
|
onClick: onToggle,
|
|
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),
|
|
4717
|
+
className: clsx("flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-lg bg-(--clarify-ui-subtle-background) text-(--clarify-ui-text) transition-colors 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),
|
|
3039
4718
|
children: [/* @__PURE__ */ jsx("span", {
|
|
3040
4719
|
className: "sm:hidden",
|
|
3041
4720
|
children: /* @__PURE__ */ jsx(ServerIcon, {
|
|
@@ -3054,7 +4733,7 @@ function ServerUrlValue(arg0) {
|
|
|
3054
4733
|
children: url
|
|
3055
4734
|
}),
|
|
3056
4735
|
/* @__PURE__ */ jsx(ChevronDownIcon, {
|
|
3057
|
-
className: "h-3.5 w-3.5 shrink-0 text-zinc-400",
|
|
4736
|
+
className: clsx("h-3.5 w-3.5 shrink-0 text-zinc-400 transition-transform", open && "rotate-180"),
|
|
3058
4737
|
"aria-hidden": "true"
|
|
3059
4738
|
})
|
|
3060
4739
|
]
|
|
@@ -3121,51 +4800,10 @@ function ServerPanel(arg0) {
|
|
|
3121
4800
|
})
|
|
3122
4801
|
});
|
|
3123
4802
|
}
|
|
3124
|
-
function AuthPanel(arg0) {
|
|
3125
|
-
const { authOptions, selectedAuthName, selectedAuth, authValues, onSelectAuth, onChangeAuthValue } = arg0;
|
|
3126
|
-
if (authOptions.length === 0) return null;
|
|
3127
|
-
return /* @__PURE__ */ jsx("div", {
|
|
3128
|
-
className: "border-t border-(--clarify-theme-tokens-colors-border) bg-(--clarify-ui-subtle-background) p-3",
|
|
3129
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
3130
|
-
className: "grid gap-3 sm:grid-cols-(--clarify-openapi-control-grid)",
|
|
3131
|
-
children: [/* @__PURE__ */ jsxs("label", {
|
|
3132
|
-
className: "flex min-w-0 flex-col gap-1.5",
|
|
3133
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
3134
|
-
className: "text-2xs font-semibold text-(--clarify-ui-text-soft)",
|
|
3135
|
-
children: "Auth"
|
|
3136
|
-
}), /* @__PURE__ */ jsx(InlineListbox, {
|
|
3137
|
-
label: "Auth",
|
|
3138
|
-
value: selectedAuthName,
|
|
3139
|
-
options: authOptions.map(({ name, scheme }) => ({
|
|
3140
|
-
value: name,
|
|
3141
|
-
label: name,
|
|
3142
|
-
description: authLabel(name, scheme)
|
|
3143
|
-
})),
|
|
3144
|
-
onChange: onSelectAuth
|
|
3145
|
-
})]
|
|
3146
|
-
}), selectedAuth ? /* @__PURE__ */ jsxs("label", {
|
|
3147
|
-
className: "flex min-w-0 flex-col gap-1.5",
|
|
3148
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
3149
|
-
className: "text-2xs font-semibold text-(--clarify-ui-text-soft)",
|
|
3150
|
-
children: "Credential"
|
|
3151
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
3152
|
-
className: "flex min-w-0 items-center rounded-md border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) px-2.5 py-1.5 shadow-xs",
|
|
3153
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
3154
|
-
className: "mr-2 shrink-0 text-2xs font-semibold text-(--clarify-ui-text-soft)",
|
|
3155
|
-
children: selectedAuth.scheme.type === "apiKey" ? selectedAuth.scheme.in ?? "apiKey" : selectedAuth.scheme.scheme ?? selectedAuth.scheme.type ?? "token"
|
|
3156
|
-
}), /* @__PURE__ */ jsx("input", {
|
|
3157
|
-
value: authValues[selectedAuth.name] ?? "",
|
|
3158
|
-
placeholder: authPlaceholder(selectedAuth),
|
|
3159
|
-
onChange: (event) => onChangeAuthValue(selectedAuth.name, event.target.value),
|
|
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)"
|
|
3161
|
-
})]
|
|
3162
|
-
})]
|
|
3163
|
-
}) : null]
|
|
3164
|
-
})
|
|
3165
|
-
});
|
|
3166
|
-
}
|
|
3167
4803
|
function EndpointIdentity(arg0) {
|
|
3168
|
-
const { method, operationSource, path, servers, selectedServerKey, selectedServer, serverVariables, serverOpen,
|
|
4804
|
+
const { method, operationSource, path, servers, selectedServerKey, selectedServer, serverVariables, serverOpen, onSelectServer, onChangeServerVariable, onToggleServer, onTryRequest } = arg0;
|
|
4805
|
+
const t = useBuiltInText();
|
|
4806
|
+
const directServerSelect = servers.length > 1 && servers.every((server) => Object.keys(server.variables ?? {}).length === 0);
|
|
3169
4807
|
const serverInteractive = servers.length > 1 || Object.keys(selectedServer.variables ?? {}).length > 0;
|
|
3170
4808
|
const [copiedUrl, setCopiedUrl] = useState(false);
|
|
3171
4809
|
const fullUrl = getFullEndpointUrl(selectedServer, serverVariables, path);
|
|
@@ -3178,58 +4816,41 @@ function EndpointIdentity(arg0) {
|
|
|
3178
4816
|
if (await copyTextToClipboard(fullUrl)) setCopiedUrl(true);
|
|
3179
4817
|
}
|
|
3180
4818
|
return /* @__PURE__ */ jsxs("div", {
|
|
3181
|
-
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",
|
|
3182
|
-
children: [
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
serverInteractive && serverOpen ? /* @__PURE__ */ jsx(ServerPanel, {
|
|
3217
|
-
servers,
|
|
3218
|
-
selectedKey: selectedServerKey,
|
|
3219
|
-
selectedServer,
|
|
3220
|
-
variables: serverVariables,
|
|
3221
|
-
onSelectServer,
|
|
3222
|
-
onChangeVariable: onChangeServerVariable
|
|
3223
|
-
}) : null,
|
|
3224
|
-
authOpen ? /* @__PURE__ */ jsx(AuthPanel, {
|
|
3225
|
-
authOptions,
|
|
3226
|
-
selectedAuthName,
|
|
3227
|
-
selectedAuth,
|
|
3228
|
-
authValues,
|
|
3229
|
-
onSelectAuth,
|
|
3230
|
-
onChangeAuthValue
|
|
3231
|
-
}) : null
|
|
3232
|
-
]
|
|
4819
|
+
className: "clarify-openai-endpoint-identity 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",
|
|
4820
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
4821
|
+
className: "flex min-w-0 items-center gap-1.5 overflow-hidden px-2.5 py-2",
|
|
4822
|
+
children: [
|
|
4823
|
+
/* @__PURE__ */ jsx(EndpointMethodBadge, { method }),
|
|
4824
|
+
operationSource === "webhook" ? /* @__PURE__ */ jsx(EndpointMethodBadge, { method: "WEBHOOK" }) : null,
|
|
4825
|
+
/* @__PURE__ */ jsx(ServerUrlValue, {
|
|
4826
|
+
servers,
|
|
4827
|
+
selectedKey: selectedServerKey,
|
|
4828
|
+
server: selectedServer,
|
|
4829
|
+
variables: serverVariables,
|
|
4830
|
+
open: serverOpen,
|
|
4831
|
+
interactive: serverInteractive,
|
|
4832
|
+
directSelect: directServerSelect,
|
|
4833
|
+
onSelect: onSelectServer,
|
|
4834
|
+
onToggle: onToggleServer
|
|
4835
|
+
}),
|
|
4836
|
+
/* @__PURE__ */ jsx(EndpointPath, {
|
|
4837
|
+
path,
|
|
4838
|
+
copied: copiedUrl,
|
|
4839
|
+
onCopy: handleCopyUrl
|
|
4840
|
+
}),
|
|
4841
|
+
onTryRequest ? /* @__PURE__ */ jsx(SendRequestButton, {
|
|
4842
|
+
label: t("openapi.tryRequest"),
|
|
4843
|
+
onClick: onTryRequest
|
|
4844
|
+
}) : null
|
|
4845
|
+
]
|
|
4846
|
+
}), serverInteractive && !directServerSelect && serverOpen ? /* @__PURE__ */ jsx(ServerPanel, {
|
|
4847
|
+
servers,
|
|
4848
|
+
selectedKey: selectedServerKey,
|
|
4849
|
+
selectedServer,
|
|
4850
|
+
variables: serverVariables,
|
|
4851
|
+
onSelectServer,
|
|
4852
|
+
onChangeVariable: onChangeServerVariable
|
|
4853
|
+
}) : null]
|
|
3233
4854
|
});
|
|
3234
4855
|
}
|
|
3235
4856
|
function OpenApiOperation(arg0) {
|
|
@@ -3242,8 +4863,9 @@ function OpenApiOperation(arg0) {
|
|
|
3242
4863
|
const authState = useOperationAuthState(spec, operation);
|
|
3243
4864
|
const [linkedExampleKey, setLinkedExampleKey] = useState("");
|
|
3244
4865
|
const [selectedResponseStatus, setSelectedResponseStatus] = useState(() => getDefaultResponseStatus(operation, spec));
|
|
4866
|
+
const [requestOpen, setRequestOpen] = useState(false);
|
|
3245
4867
|
return /* @__PURE__ */ jsxs("section", {
|
|
3246
|
-
className: "clarify-
|
|
4868
|
+
className: "clarify-openai-endpoint scroll-mt-24 pb-16 first:pt-0 last:pb-0",
|
|
3247
4869
|
"aria-labelledby": id,
|
|
3248
4870
|
children: [
|
|
3249
4871
|
/* @__PURE__ */ jsx(Heading, {
|
|
@@ -3259,23 +4881,19 @@ function OpenApiOperation(arg0) {
|
|
|
3259
4881
|
selectedServer: serverState.selectedServer,
|
|
3260
4882
|
serverVariables: serverState.serverVariables,
|
|
3261
4883
|
serverOpen: serverState.serverOpen,
|
|
3262
|
-
authOptions: authState.authOptions,
|
|
3263
|
-
selectedAuthName: authState.selectedAuthName,
|
|
3264
|
-
selectedAuth: authState.selectedAuth,
|
|
3265
|
-
authValues: authState.authValues,
|
|
3266
|
-
authOpen: authState.authOpen,
|
|
3267
4884
|
onSelectServer: serverState.onSelectServer,
|
|
3268
4885
|
onChangeServerVariable: serverState.onChangeServerVariable,
|
|
3269
|
-
onToggleServer:
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
4886
|
+
onToggleServer: serverState.onToggleServer,
|
|
4887
|
+
onTryRequest: () => setRequestOpen(true)
|
|
4888
|
+
}),
|
|
4889
|
+
/* @__PURE__ */ jsx(OpenApiRequestDialog, {
|
|
4890
|
+
open: requestOpen,
|
|
4891
|
+
onClose: () => setRequestOpen(false),
|
|
4892
|
+
spec,
|
|
4893
|
+
path,
|
|
4894
|
+
method,
|
|
4895
|
+
operation,
|
|
4896
|
+
operationSource
|
|
3279
4897
|
}),
|
|
3280
4898
|
/* @__PURE__ */ jsx(EndpointRequest, {
|
|
3281
4899
|
spec,
|
|
@@ -3309,6 +4927,6 @@ function OpenApiOperation(arg0) {
|
|
|
3309
4927
|
});
|
|
3310
4928
|
}
|
|
3311
4929
|
//#endregion
|
|
3312
|
-
export {
|
|
4930
|
+
export { Code as A, GridPattern as C, Tag as D, Heading as E, CardGroup as F, Callout as I, Button as L, Pre as M, Mermaid as N, Feedback as O, Card as P, Prose as S, Logo as T, WebFrame as _, ResponseExamplesPanel as a, Step as b, getAuthOptions as c, getOpenApiOperationEntry as d, listOpenApiOperations as f, primitives_exports as g, Markdown as h, RequestExamplesPanel as i, CodeGroup as j, Collapse as k, getServerKey as l, getRequestBody$1 as m, OpenApiOperation as n, authPlaceholder as o, getMediaTypeEntries as p, OpenApiRequestWorkbench as r, defaultServerVariables as s, EndpointIdentity as t, getServers as u, TabItem as v, HeroPattern as w, Steps as x, Tabs as y };
|
|
3313
4931
|
|
|
3314
|
-
//# sourceMappingURL=OpenApiOperation-
|
|
4932
|
+
//# sourceMappingURL=OpenApiOperation-C2vJztWZ.js.map
|