@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.
@@ -868,16 +868,16 @@ function Note(arg0) {
868
868
  });
869
869
  }
870
870
  function Row(arg0) {
871
- const { children } = arg0;
871
+ const { children, className } = arg0;
872
872
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
873
- className: "clarify-row grid grid-cols-1 items-start gap-x-8 gap-y-10 xl:max-w-none xl:grid-cols-2",
873
+ className: (0, clsx.default)("clarify-row grid grid-cols-1 items-start gap-x-8 gap-y-10 xl:max-w-none xl:grid-cols-2", className),
874
874
  children
875
875
  });
876
876
  }
877
877
  function Col(arg0) {
878
878
  const { children, sticky = false } = arg0;
879
879
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
880
- className: (0, clsx.default)("clarify-col *:first:mt-0 *:last:mb-0", sticky && "xl:sticky xl:top-24"),
880
+ className: (0, clsx.default)("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"),
881
881
  children
882
882
  });
883
883
  }
@@ -2051,7 +2051,10 @@ function SchemaNode(arg0) {
2051
2051
  }) : null]
2052
2052
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2053
2053
  className: "mt-0.5 text-sm/5 text-(--clarify-ui-text-soft) *:first:mt-0 *:last:mb-0",
2054
- children: [node.description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, { children: node.description }) : fallbackDescription, node.details ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2054
+ children: [node.description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, {
2055
+ className: "*:first:mt-0 *:last:mb-0",
2056
+ children: node.description
2057
+ }) : fallbackDescription, node.details ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2055
2058
  className: "text-xs text-(--clarify-ui-text-faint)",
2056
2059
  children: node.details
2057
2060
  }) : null]
@@ -2107,7 +2110,10 @@ function ParameterList(arg0) {
2107
2110
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: title }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Properties, { children: parameters.map((parameter) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Property, {
2108
2111
  name: parameter.name ?? t("openapi.parameter"),
2109
2112
  type: [schemaToType(parameter.schema), parameter.required ? t("openapi.requiredBadge") : void 0].filter(Boolean).join(", ") || void 0,
2110
- children: parameter.description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, { children: parameter.description }) : t("openapi.operationParameter")
2113
+ children: parameter.description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, {
2114
+ className: "*:first:mt-0 *:last:mb-0",
2115
+ children: parameter.description
2116
+ }) : t("openapi.operationParameter")
2111
2117
  }, `${parameter.in}-${parameter.name}`)) })] });
2112
2118
  }
2113
2119
  function ResponseList(arg0) {
@@ -2119,33 +2125,78 @@ function ResponseList(arg0) {
2119
2125
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Property, {
2120
2126
  name: status,
2121
2127
  type: schemaToType(getJsonLikeContent(response.content, spec)?.value.schema),
2122
- children: response.description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, { children: response.description }) : `${t("openapi.response")}.`
2128
+ children: response.description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, {
2129
+ className: "*:first:mt-0 *:last:mb-0",
2130
+ children: response.description
2131
+ }) : `${t("openapi.response")}.`
2123
2132
  }, status);
2124
2133
  }) })] });
2125
2134
  }
2126
2135
  //#endregion
2127
- //#region source/openapi/components/OpenApiOperation.tsx
2128
- function EndpointExamples(arg0) {
2129
- const { spec, path, method, operation, parameters, requestContents, selectedRequestMediaType, onSelectRequestMediaType, selectedServer, serverVariables, auth } = arg0;
2130
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2131
- className: "space-y-6",
2132
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestExamplesPanel, {
2133
- spec,
2134
- path,
2135
- method,
2136
- parameters,
2137
- requestContents,
2138
- selectedMediaType: selectedRequestMediaType,
2139
- onSelectMediaType: onSelectRequestMediaType,
2140
- selectedServer,
2141
- serverVariables,
2142
- auth
2143
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseExamplesPanel, {
2136
+ //#region source/openapi/components/EndpointSections.tsx
2137
+ function EndpointRequest(arg0) {
2138
+ const { spec, path, method, description, groupedParameters, parameters, requestBody, requestContents, requestSchema, selectedRequestMediaType, onSelectRequestMediaType, selectedServer, serverVariables, auth } = arg0;
2139
+ const t = require_PageActions.useBuiltInText();
2140
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Row, {
2141
+ className: "relative mt-6",
2142
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Col, { children: [
2143
+ description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, { children: description }) : null,
2144
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ParameterList, {
2145
+ title: t("openapi.pathParameters"),
2146
+ parameters: groupedParameters.path
2147
+ }),
2148
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ParameterList, {
2149
+ title: t("openapi.queryParameters"),
2150
+ parameters: groupedParameters.query
2151
+ }),
2152
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ParameterList, {
2153
+ title: t("openapi.headers"),
2154
+ parameters: groupedParameters.header
2155
+ }),
2156
+ requestBody && requestContents.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
2157
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: t("openapi.requestBody") }),
2158
+ typeof requestBody.description === "string" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, { children: requestBody.description }) : null,
2159
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaProperties, {
2160
+ title: t("openapi.bodyProperties"),
2161
+ schema: requestSchema,
2162
+ spec
2163
+ })
2164
+ ] }) : null
2165
+ ] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Col, {
2166
+ sticky: true,
2167
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestExamplesPanel, {
2168
+ spec,
2169
+ path,
2170
+ method,
2171
+ parameters,
2172
+ requestContents,
2173
+ selectedMediaType: selectedRequestMediaType,
2174
+ onSelectMediaType: onSelectRequestMediaType,
2175
+ selectedServer,
2176
+ serverVariables,
2177
+ auth
2178
+ })
2179
+ })]
2180
+ });
2181
+ }
2182
+ function EndpointResponse(arg0) {
2183
+ const { spec, operation } = arg0;
2184
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Row, {
2185
+ className: "relative mt-6",
2186
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Col, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseList, {
2144
2187
  operation,
2145
2188
  spec
2189
+ }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Col, {
2190
+ sticky: true,
2191
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseExamplesPanel, {
2192
+ operation,
2193
+ spec
2194
+ })
2146
2195
  })]
2147
2196
  });
2148
2197
  }
2198
+ //#endregion
2199
+ //#region source/openapi/components/OpenApiOperation.tsx
2149
2200
  var endpointMethodStyles = {
2150
2201
  GET: "bg-emerald-400/15 text-emerald-600 dark:bg-emerald-400/20 dark:text-emerald-300",
2151
2202
  POST: "bg-sky-400/15 text-sky-600 dark:bg-sky-400/20 dark:text-sky-300",
@@ -2206,8 +2257,25 @@ function getServerPreviewUrl(server, variables) {
2206
2257
  return (server.url ?? "").replace(/\{([^}]+)\}/g, (_, name) => variables[name] ?? server.variables?.[name]?.default ?? `{${name}}`);
2207
2258
  }
2208
2259
  function ServerUrlValue(arg0) {
2209
- const { server, variables, open, onToggle } = arg0;
2260
+ const { server, variables, open, interactive, onToggle } = arg0;
2210
2261
  const url = getServerPreviewUrl(server, variables);
2262
+ if (!interactive) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2263
+ "aria-label": "Server",
2264
+ 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",
2265
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2266
+ className: "sm:hidden",
2267
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ServerIcon, {
2268
+ className: "h-4 w-4",
2269
+ "aria-hidden": "true"
2270
+ })
2271
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2272
+ className: "hidden min-w-0 items-center overflow-hidden sm:flex",
2273
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2274
+ className: "truncate font-semibold text-xs",
2275
+ children: url
2276
+ })
2277
+ })]
2278
+ });
2211
2279
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
2212
2280
  type: "button",
2213
2281
  "aria-expanded": open,
@@ -2334,6 +2402,7 @@ function AuthPanel(arg0) {
2334
2402
  function EndpointIdentity(arg0) {
2335
2403
  const { method, path, servers, selectedServerKey, selectedServer, serverVariables, serverOpen, authOptions, selectedAuthName, selectedAuth, authValues, authOpen, onSelectServer, onChangeServerVariable, onToggleServer, onToggleAuth, onSelectAuth, onChangeAuthValue } = arg0;
2336
2404
  const segments = path.split("/").filter(Boolean);
2405
+ const serverInteractive = servers.length > 1 || Object.keys(selectedServer.variables ?? {}).length > 0;
2337
2406
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2338
2407
  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",
2339
2408
  children: [
@@ -2345,6 +2414,7 @@ function EndpointIdentity(arg0) {
2345
2414
  server: selectedServer,
2346
2415
  variables: serverVariables,
2347
2416
  open: serverOpen,
2417
+ interactive: serverInteractive,
2348
2418
  onToggle: onToggleServer
2349
2419
  }),
2350
2420
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -2382,7 +2452,7 @@ function EndpointIdentity(arg0) {
2382
2452
  }) : null
2383
2453
  ]
2384
2454
  }),
2385
- serverOpen ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ServerPanel, {
2455
+ serverInteractive && serverOpen ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ServerPanel, {
2386
2456
  servers,
2387
2457
  selectedKey: selectedServerKey,
2388
2458
  selectedServer,
@@ -2403,7 +2473,6 @@ function EndpointIdentity(arg0) {
2403
2473
  }
2404
2474
  function OpenApiOperation(arg0) {
2405
2475
  const { spec, path, method, operation } = arg0;
2406
- const t = require_PageActions.useBuiltInText();
2407
2476
  const id = (0, github_slugger.slug)(`${method.toLowerCase()} ${path}`);
2408
2477
  const summary = operation.summary ?? `${method} ${path}`;
2409
2478
  const description = operation.description;
@@ -2437,6 +2506,10 @@ function OpenApiOperation(arg0) {
2437
2506
  className: "clarify-api-endpoint scroll-mt-24 py-16 first:pt-0 last:pb-0",
2438
2507
  "aria-labelledby": id,
2439
2508
  children: [
2509
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Heading, {
2510
+ id,
2511
+ children: summary
2512
+ }),
2440
2513
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointIdentity, {
2441
2514
  method,
2442
2515
  path,
@@ -2473,57 +2546,26 @@ function OpenApiOperation(arg0) {
2473
2546
  [name]: value
2474
2547
  }))
2475
2548
  }),
2476
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Heading, {
2477
- id,
2478
- className: "mt-6",
2479
- children: summary
2549
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointRequest, {
2550
+ spec,
2551
+ path,
2552
+ method,
2553
+ description,
2554
+ groupedParameters,
2555
+ parameters,
2556
+ requestBody,
2557
+ requestContents,
2558
+ requestSchema,
2559
+ selectedRequestMediaType: selectedRequestContent?.mediaType ?? "",
2560
+ onSelectRequestMediaType: setSelectedRequestMediaType,
2561
+ selectedServer,
2562
+ serverVariables,
2563
+ auth: authInput
2480
2564
  }),
2481
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Row, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Col, { children: [
2482
- description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, {
2483
- className: "mt-4 *:first:mt-0 *:last:mb-0",
2484
- children: description
2485
- }) : null,
2486
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ParameterList, {
2487
- title: t("openapi.pathParameters"),
2488
- parameters: groupedParameters.path
2489
- }),
2490
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ParameterList, {
2491
- title: t("openapi.queryParameters"),
2492
- parameters: groupedParameters.query
2493
- }),
2494
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ParameterList, {
2495
- title: t("openapi.headers"),
2496
- parameters: groupedParameters.header
2497
- }),
2498
- requestBody && requestContents.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
2499
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: t("openapi.requestBody") }),
2500
- typeof requestBody.description === "string" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, { children: requestBody.description }) : null,
2501
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaProperties, {
2502
- title: t("openapi.bodyProperties"),
2503
- schema: requestSchema,
2504
- spec
2505
- })
2506
- ] }) : null,
2507
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseList, {
2508
- operation,
2509
- spec
2510
- })
2511
- ] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Col, {
2512
- sticky: true,
2513
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointExamples, {
2514
- spec,
2515
- path,
2516
- method,
2517
- operation,
2518
- parameters,
2519
- requestContents,
2520
- selectedRequestMediaType: selectedRequestContent?.mediaType ?? "",
2521
- onSelectRequestMediaType: setSelectedRequestMediaType,
2522
- selectedServer,
2523
- serverVariables,
2524
- auth: authInput
2525
- })
2526
- })] })
2565
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointResponse, {
2566
+ spec,
2567
+ operation
2568
+ })
2527
2569
  ]
2528
2570
  });
2529
2571
  }
@@ -2703,4 +2745,4 @@ Object.defineProperty(exports, "primitives_exports", {
2703
2745
  }
2704
2746
  });
2705
2747
 
2706
- //# sourceMappingURL=OpenApiOperation-C4xZu4i0.cjs.map
2748
+ //# sourceMappingURL=OpenApiOperation-BcyW_ULy.cjs.map