@clarify-labs/renderer 0.7.1 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -877,16 +877,16 @@ function Note(arg0) {
877
877
  });
878
878
  }
879
879
  function Row(arg0) {
880
- const { children } = arg0;
880
+ const { children, className } = arg0;
881
881
  return /* @__PURE__ */ jsx("div", {
882
- className: "clarify-row grid grid-cols-1 items-start gap-x-8 gap-y-10 xl:max-w-none xl:grid-cols-2",
882
+ className: clsx("clarify-row grid grid-cols-1 items-start gap-x-8 gap-y-10 xl:max-w-none xl:grid-cols-2", className),
883
883
  children
884
884
  });
885
885
  }
886
886
  function Col(arg0) {
887
887
  const { children, sticky = false } = arg0;
888
888
  return /* @__PURE__ */ jsx("div", {
889
- className: clsx("clarify-col *:first:mt-0 *:last:mb-0", sticky && "xl:sticky xl:top-24"),
889
+ className: clsx("clarify-col *:first:mt-0 *:last:mb-0", sticky && "xl:sticky xl:top-[calc(var(--clarify-header-offset,3.5rem)+1.5rem)] xl:self-start"),
890
890
  children
891
891
  });
892
892
  }
@@ -2060,7 +2060,10 @@ function SchemaNode(arg0) {
2060
2060
  }) : null]
2061
2061
  }), /* @__PURE__ */ jsxs("div", {
2062
2062
  className: "mt-0.5 text-sm/5 text-(--clarify-ui-text-soft) *:first:mt-0 *:last:mb-0",
2063
- children: [node.description ? /* @__PURE__ */ jsx(Markdown, { children: node.description }) : fallbackDescription, node.details ? /* @__PURE__ */ jsx("p", {
2063
+ children: [node.description ? /* @__PURE__ */ jsx(Markdown, {
2064
+ className: "*:first:mt-0 *:last:mb-0",
2065
+ children: node.description
2066
+ }) : fallbackDescription, node.details ? /* @__PURE__ */ jsx("p", {
2064
2067
  className: "text-xs text-(--clarify-ui-text-faint)",
2065
2068
  children: node.details
2066
2069
  }) : null]
@@ -2116,7 +2119,10 @@ function ParameterList(arg0) {
2116
2119
  return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", { children: title }), /* @__PURE__ */ jsx(Properties, { children: parameters.map((parameter) => /* @__PURE__ */ jsx(Property, {
2117
2120
  name: parameter.name ?? t("openapi.parameter"),
2118
2121
  type: [schemaToType(parameter.schema), parameter.required ? t("openapi.requiredBadge") : void 0].filter(Boolean).join(", ") || void 0,
2119
- children: parameter.description ? /* @__PURE__ */ jsx(Markdown, { children: parameter.description }) : t("openapi.operationParameter")
2122
+ children: parameter.description ? /* @__PURE__ */ jsx(Markdown, {
2123
+ className: "*:first:mt-0 *:last:mb-0",
2124
+ children: parameter.description
2125
+ }) : t("openapi.operationParameter")
2120
2126
  }, `${parameter.in}-${parameter.name}`)) })] });
2121
2127
  }
2122
2128
  function ResponseList(arg0) {
@@ -2128,33 +2134,78 @@ function ResponseList(arg0) {
2128
2134
  return /* @__PURE__ */ jsx(Property, {
2129
2135
  name: status,
2130
2136
  type: schemaToType(getJsonLikeContent(response.content, spec)?.value.schema),
2131
- children: response.description ? /* @__PURE__ */ jsx(Markdown, { children: response.description }) : `${t("openapi.response")}.`
2137
+ children: response.description ? /* @__PURE__ */ jsx(Markdown, {
2138
+ className: "*:first:mt-0 *:last:mb-0",
2139
+ children: response.description
2140
+ }) : `${t("openapi.response")}.`
2132
2141
  }, status);
2133
2142
  }) })] });
2134
2143
  }
2135
2144
  //#endregion
2136
- //#region source/openapi/components/OpenApiOperation.tsx
2137
- function EndpointExamples(arg0) {
2138
- const { spec, path, method, operation, parameters, requestContents, selectedRequestMediaType, onSelectRequestMediaType, selectedServer, serverVariables, auth } = arg0;
2139
- return /* @__PURE__ */ jsxs("div", {
2140
- className: "space-y-6",
2141
- children: [/* @__PURE__ */ jsx(RequestExamplesPanel, {
2142
- spec,
2143
- path,
2144
- method,
2145
- parameters,
2146
- requestContents,
2147
- selectedMediaType: selectedRequestMediaType,
2148
- onSelectMediaType: onSelectRequestMediaType,
2149
- selectedServer,
2150
- serverVariables,
2151
- auth
2152
- }), /* @__PURE__ */ jsx(ResponseExamplesPanel, {
2145
+ //#region source/openapi/components/EndpointSections.tsx
2146
+ function EndpointRequest(arg0) {
2147
+ const { spec, path, method, description, groupedParameters, parameters, requestBody, requestContents, requestSchema, selectedRequestMediaType, onSelectRequestMediaType, selectedServer, serverVariables, auth } = arg0;
2148
+ const t = useBuiltInText();
2149
+ return /* @__PURE__ */ jsxs(Row, {
2150
+ className: "relative mt-6",
2151
+ children: [/* @__PURE__ */ jsxs(Col, { children: [
2152
+ description ? /* @__PURE__ */ jsx(Markdown, { children: description }) : null,
2153
+ /* @__PURE__ */ jsx(ParameterList, {
2154
+ title: t("openapi.pathParameters"),
2155
+ parameters: groupedParameters.path
2156
+ }),
2157
+ /* @__PURE__ */ jsx(ParameterList, {
2158
+ title: t("openapi.queryParameters"),
2159
+ parameters: groupedParameters.query
2160
+ }),
2161
+ /* @__PURE__ */ jsx(ParameterList, {
2162
+ title: t("openapi.headers"),
2163
+ parameters: groupedParameters.header
2164
+ }),
2165
+ requestBody && requestContents.length > 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
2166
+ /* @__PURE__ */ jsx("h3", { children: t("openapi.requestBody") }),
2167
+ typeof requestBody.description === "string" ? /* @__PURE__ */ jsx(Markdown, { children: requestBody.description }) : null,
2168
+ /* @__PURE__ */ jsx(SchemaProperties, {
2169
+ title: t("openapi.bodyProperties"),
2170
+ schema: requestSchema,
2171
+ spec
2172
+ })
2173
+ ] }) : null
2174
+ ] }), /* @__PURE__ */ jsx(Col, {
2175
+ sticky: true,
2176
+ children: /* @__PURE__ */ jsx(RequestExamplesPanel, {
2177
+ spec,
2178
+ path,
2179
+ method,
2180
+ parameters,
2181
+ requestContents,
2182
+ selectedMediaType: selectedRequestMediaType,
2183
+ onSelectMediaType: onSelectRequestMediaType,
2184
+ selectedServer,
2185
+ serverVariables,
2186
+ auth
2187
+ })
2188
+ })]
2189
+ });
2190
+ }
2191
+ function EndpointResponse(arg0) {
2192
+ const { spec, operation } = arg0;
2193
+ return /* @__PURE__ */ jsxs(Row, {
2194
+ className: "relative mt-6",
2195
+ children: [/* @__PURE__ */ jsx(Col, { children: /* @__PURE__ */ jsx(ResponseList, {
2153
2196
  operation,
2154
2197
  spec
2198
+ }) }), /* @__PURE__ */ jsx(Col, {
2199
+ sticky: true,
2200
+ children: /* @__PURE__ */ jsx(ResponseExamplesPanel, {
2201
+ operation,
2202
+ spec
2203
+ })
2155
2204
  })]
2156
2205
  });
2157
2206
  }
2207
+ //#endregion
2208
+ //#region source/openapi/components/OpenApiOperation.tsx
2158
2209
  var endpointMethodStyles = {
2159
2210
  GET: "bg-emerald-400/15 text-emerald-600 dark:bg-emerald-400/20 dark:text-emerald-300",
2160
2211
  POST: "bg-sky-400/15 text-sky-600 dark:bg-sky-400/20 dark:text-sky-300",
@@ -2215,8 +2266,25 @@ function getServerPreviewUrl(server, variables) {
2215
2266
  return (server.url ?? "").replace(/\{([^}]+)\}/g, (_, name) => variables[name] ?? server.variables?.[name]?.default ?? `{${name}}`);
2216
2267
  }
2217
2268
  function ServerUrlValue(arg0) {
2218
- const { server, variables, open, onToggle } = arg0;
2269
+ const { server, variables, open, interactive, onToggle } = arg0;
2219
2270
  const url = getServerPreviewUrl(server, variables);
2271
+ if (!interactive) return /* @__PURE__ */ jsxs("span", {
2272
+ "aria-label": "Server",
2273
+ className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-(--clarify-ui-subtle-background) text-(--clarify-ui-text-foreground) sm:w-auto sm:min-w-16 sm:max-w-(--clarify-server-url-max-width) sm:px-1.5",
2274
+ children: [/* @__PURE__ */ jsx("span", {
2275
+ className: "sm:hidden",
2276
+ children: /* @__PURE__ */ jsx(ServerIcon, {
2277
+ className: "h-4 w-4",
2278
+ "aria-hidden": "true"
2279
+ })
2280
+ }), /* @__PURE__ */ jsx("span", {
2281
+ className: "hidden min-w-0 items-center overflow-hidden sm:flex",
2282
+ children: /* @__PURE__ */ jsx("span", {
2283
+ className: "truncate font-semibold text-xs",
2284
+ children: url
2285
+ })
2286
+ })]
2287
+ });
2220
2288
  return /* @__PURE__ */ jsxs("button", {
2221
2289
  type: "button",
2222
2290
  "aria-expanded": open,
@@ -2343,6 +2411,7 @@ function AuthPanel(arg0) {
2343
2411
  function EndpointIdentity(arg0) {
2344
2412
  const { method, path, servers, selectedServerKey, selectedServer, serverVariables, serverOpen, authOptions, selectedAuthName, selectedAuth, authValues, authOpen, onSelectServer, onChangeServerVariable, onToggleServer, onToggleAuth, onSelectAuth, onChangeAuthValue } = arg0;
2345
2413
  const segments = path.split("/").filter(Boolean);
2414
+ const serverInteractive = servers.length > 1 || Object.keys(selectedServer.variables ?? {}).length > 0;
2346
2415
  return /* @__PURE__ */ jsxs("div", {
2347
2416
  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",
2348
2417
  children: [
@@ -2354,6 +2423,7 @@ function EndpointIdentity(arg0) {
2354
2423
  server: selectedServer,
2355
2424
  variables: serverVariables,
2356
2425
  open: serverOpen,
2426
+ interactive: serverInteractive,
2357
2427
  onToggle: onToggleServer
2358
2428
  }),
2359
2429
  /* @__PURE__ */ jsx("div", {
@@ -2391,7 +2461,7 @@ function EndpointIdentity(arg0) {
2391
2461
  }) : null
2392
2462
  ]
2393
2463
  }),
2394
- serverOpen ? /* @__PURE__ */ jsx(ServerPanel, {
2464
+ serverInteractive && serverOpen ? /* @__PURE__ */ jsx(ServerPanel, {
2395
2465
  servers,
2396
2466
  selectedKey: selectedServerKey,
2397
2467
  selectedServer,
@@ -2412,7 +2482,6 @@ function EndpointIdentity(arg0) {
2412
2482
  }
2413
2483
  function OpenApiOperation(arg0) {
2414
2484
  const { spec, path, method, operation } = arg0;
2415
- const t = useBuiltInText();
2416
2485
  const id = slug(`${method.toLowerCase()} ${path}`);
2417
2486
  const summary = operation.summary ?? `${method} ${path}`;
2418
2487
  const description = operation.description;
@@ -2446,6 +2515,10 @@ function OpenApiOperation(arg0) {
2446
2515
  className: "clarify-api-endpoint scroll-mt-24 py-16 first:pt-0 last:pb-0",
2447
2516
  "aria-labelledby": id,
2448
2517
  children: [
2518
+ /* @__PURE__ */ jsx(Heading, {
2519
+ id,
2520
+ children: summary
2521
+ }),
2449
2522
  /* @__PURE__ */ jsx(EndpointIdentity, {
2450
2523
  method,
2451
2524
  path,
@@ -2482,61 +2555,30 @@ function OpenApiOperation(arg0) {
2482
2555
  [name]: value
2483
2556
  }))
2484
2557
  }),
2485
- /* @__PURE__ */ jsx(Heading, {
2486
- id,
2487
- className: "mt-6",
2488
- children: summary
2558
+ /* @__PURE__ */ jsx(EndpointRequest, {
2559
+ spec,
2560
+ path,
2561
+ method,
2562
+ description,
2563
+ groupedParameters,
2564
+ parameters,
2565
+ requestBody,
2566
+ requestContents,
2567
+ requestSchema,
2568
+ selectedRequestMediaType: selectedRequestContent?.mediaType ?? "",
2569
+ onSelectRequestMediaType: setSelectedRequestMediaType,
2570
+ selectedServer,
2571
+ serverVariables,
2572
+ auth: authInput
2489
2573
  }),
2490
- /* @__PURE__ */ jsxs(Row, { children: [/* @__PURE__ */ jsxs(Col, { children: [
2491
- description ? /* @__PURE__ */ jsx(Markdown, {
2492
- className: "mt-4 *:first:mt-0 *:last:mb-0",
2493
- children: description
2494
- }) : null,
2495
- /* @__PURE__ */ jsx(ParameterList, {
2496
- title: t("openapi.pathParameters"),
2497
- parameters: groupedParameters.path
2498
- }),
2499
- /* @__PURE__ */ jsx(ParameterList, {
2500
- title: t("openapi.queryParameters"),
2501
- parameters: groupedParameters.query
2502
- }),
2503
- /* @__PURE__ */ jsx(ParameterList, {
2504
- title: t("openapi.headers"),
2505
- parameters: groupedParameters.header
2506
- }),
2507
- requestBody && requestContents.length > 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
2508
- /* @__PURE__ */ jsx("h3", { children: t("openapi.requestBody") }),
2509
- typeof requestBody.description === "string" ? /* @__PURE__ */ jsx(Markdown, { children: requestBody.description }) : null,
2510
- /* @__PURE__ */ jsx(SchemaProperties, {
2511
- title: t("openapi.bodyProperties"),
2512
- schema: requestSchema,
2513
- spec
2514
- })
2515
- ] }) : null,
2516
- /* @__PURE__ */ jsx(ResponseList, {
2517
- operation,
2518
- spec
2519
- })
2520
- ] }), /* @__PURE__ */ jsx(Col, {
2521
- sticky: true,
2522
- children: /* @__PURE__ */ jsx(EndpointExamples, {
2523
- spec,
2524
- path,
2525
- method,
2526
- operation,
2527
- parameters,
2528
- requestContents,
2529
- selectedRequestMediaType: selectedRequestContent?.mediaType ?? "",
2530
- onSelectRequestMediaType: setSelectedRequestMediaType,
2531
- selectedServer,
2532
- serverVariables,
2533
- auth: authInput
2534
- })
2535
- })] })
2574
+ /* @__PURE__ */ jsx(EndpointResponse, {
2575
+ spec,
2576
+ operation
2577
+ })
2536
2578
  ]
2537
2579
  });
2538
2580
  }
2539
2581
  //#endregion
2540
2582
  export { Code as C, CardGroup as D, Card as E, Callout as O, Collapse as S, Pre as T, HeroPattern as _, authPlaceholder as a, Tag as b, getServerKey as c, getRequestBody$1 as d, Markdown as f, GridPattern as g, Prose as h, ResponseExamplesPanel as i, Button as k, getServers as l, WebFrame as m, OpenApiOperation as n, defaultServerVariables as o, primitives_exports as p, RequestExamplesPanel as r, getAuthOptions as s, EndpointIdentity as t, getMediaTypeEntries as u, Logo as v, CodeGroup as w, Feedback as x, Heading as y };
2541
2583
 
2542
- //# sourceMappingURL=OpenApiOperation-LIL7bqxW.js.map
2584
+ //# sourceMappingURL=OpenApiOperation-tUKf7lZ4.js.map