zudoku 0.23.5 → 0.23.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/lib/components/navigation/SidebarBadge.d.ts +0 -9
  2. package/dist/lib/components/navigation/SidebarBadge.js +0 -9
  3. package/dist/lib/components/navigation/SidebarBadge.js.map +1 -1
  4. package/dist/lib/plugins/openapi/OperationList.js +3 -1
  5. package/dist/lib/plugins/openapi/OperationList.js.map +1 -1
  6. package/dist/lib/plugins/openapi/OperationListItem.d.ts +2 -1
  7. package/dist/lib/plugins/openapi/OperationListItem.js +14 -4
  8. package/dist/lib/plugins/openapi/OperationListItem.js.map +1 -1
  9. package/dist/lib/plugins/openapi/Sidecar.js +2 -12
  10. package/dist/lib/plugins/openapi/Sidecar.js.map +1 -1
  11. package/dist/lib/plugins/openapi/util/methodToColor.d.ts +20 -0
  12. package/dist/lib/plugins/openapi/util/methodToColor.js +24 -0
  13. package/dist/lib/plugins/openapi/util/methodToColor.js.map +1 -0
  14. package/dist/vite/plugin-api.js +4 -1
  15. package/dist/vite/plugin-api.js.map +1 -1
  16. package/lib/{OperationList-wvY-BrxS.js → OperationList-n4U_BHmO.js} +1715 -1683
  17. package/lib/OperationList-n4U_BHmO.js.map +1 -0
  18. package/lib/StaggeredRender-DgsamH_G.js +17 -0
  19. package/lib/StaggeredRender-DgsamH_G.js.map +1 -0
  20. package/lib/{index-C_ul-2fb.js → index-DStSNvP-.js} +2 -2
  21. package/lib/{index-C_ul-2fb.js.map → index-DStSNvP-.js.map} +1 -1
  22. package/lib/zudoku.components.js +385 -363
  23. package/lib/zudoku.components.js.map +1 -1
  24. package/lib/zudoku.plugin-openapi.js +1 -1
  25. package/package.json +1 -1
  26. package/src/lib/components/navigation/SidebarBadge.tsx +0 -10
  27. package/src/lib/plugins/openapi/OperationList.tsx +3 -0
  28. package/src/lib/plugins/openapi/OperationListItem.tsx +31 -2
  29. package/src/lib/plugins/openapi/Sidecar.tsx +2 -16
  30. package/src/lib/plugins/openapi/util/methodToColor.ts +27 -0
  31. package/lib/OperationList-wvY-BrxS.js.map +0 -1
  32. package/lib/SidebarBadge-Bm793GDY.js +0 -51
  33. package/lib/SidebarBadge-Bm793GDY.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import "./jsx-runtime-Dx-03ztt.js";
2
2
  import "./chunk-D52XG6IA-Dl7HLe6j.js";
3
- import { o as a } from "./index-C_ul-2fb.js";
3
+ import { o as a } from "./index-DStSNvP-.js";
4
4
  import "./utils-B4O1uet5.js";
5
5
  import "lucide-react";
6
6
  import "./hook-DgGeo5iL.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zudoku",
3
- "version": "0.23.5",
3
+ "version": "0.23.6",
4
4
  "type": "module",
5
5
  "homepage": "https://zudoku.dev",
6
6
  "repository": {
@@ -1,15 +1,5 @@
1
1
  import { cn } from "../../util/cn.js";
2
2
 
3
- export const TextColorMap = {
4
- green: "text-green-600",
5
- blue: "text-sky-600",
6
- yellow: "text-yellow-600",
7
- red: "text-red-600",
8
- purple: "text-purple-600",
9
- indigo: "text-indigo-600",
10
- gray: "text-gray-600",
11
- };
12
-
13
3
  export const ColorMap = {
14
4
  green: "bg-green-400 dark:bg-green-800",
15
5
  blue: "bg-sky-400 dark:bg-sky-800",
@@ -9,6 +9,7 @@ import {
9
9
  SelectTrigger,
10
10
  SelectValue,
11
11
  } from "zudoku/ui/Select.js";
12
+ import { useSelectedServerStore } from "../../authentication/state.js";
12
13
  import { CategoryHeading } from "../../components/CategoryHeading.js";
13
14
  import { Heading } from "../../components/Heading.js";
14
15
  import { Markdown, ProseClasses } from "../../components/Markdown.js";
@@ -110,6 +111,7 @@ const AllOperationsQuery = graphql(/* GraphQL */ `
110
111
  export const OperationList = () => {
111
112
  const { input, type, versions, version } = useOasConfig();
112
113
  const query = useCreateQuery(AllOperationsQuery, { input, type });
114
+ const { selectedServer } = useSelectedServerStore();
113
115
  const result = useSuspenseQuery(query);
114
116
  const title = result.data.schema.title;
115
117
  const summary = result.data.schema.summary;
@@ -185,6 +187,7 @@ export const OperationList = () => {
185
187
  <StaggeredRender>
186
188
  {tag.operations.map((fragment) => (
187
189
  <OperationListItem
190
+ serverUrl={selectedServer ?? result.data.schema.url}
188
191
  key={fragment.slug}
189
192
  operationFragment={fragment}
190
193
  />
@@ -1,4 +1,4 @@
1
- import { useState } from "react";
1
+ import { useRef, useState } from "react";
2
2
  import { Heading } from "../../components/Heading.js";
3
3
  import { Markdown, ProseClasses } from "../../components/Markdown.js";
4
4
  import { Tabs, TabsContent, TabsList, TabsTrigger } from "../../ui/Tabs.js";
@@ -9,20 +9,24 @@ import { ParameterList } from "./ParameterList.js";
9
9
  import { Sidecar } from "./Sidecar.js";
10
10
  import { FragmentType, useFragment } from "./graphql/index.js";
11
11
  import { SchemaView } from "./schema/SchemaView.js";
12
+ import { methodForColor } from "./util/methodToColor.js";
12
13
 
13
14
  export const PARAM_GROUPS = ["path", "query", "header", "cookie"] as const;
14
15
  export type ParameterGroup = (typeof PARAM_GROUPS)[number];
15
16
 
16
17
  export const OperationListItem = ({
17
18
  operationFragment,
19
+ serverUrl,
18
20
  }: {
19
21
  operationFragment: FragmentType<typeof OperationsFragment>;
22
+ serverUrl?: string;
20
23
  }) => {
21
24
  const operation = useFragment(OperationsFragment, operationFragment);
22
25
  const groupedParameters = groupBy(
23
26
  operation.parameters ?? [],
24
27
  (param) => param.in,
25
28
  );
29
+ const parentRef = useRef<HTMLDivElement>(null);
26
30
 
27
31
  const first = operation.responses.at(0);
28
32
  const [selectedResponse, setSelectedResponse] = useState(first?.statusCode);
@@ -30,12 +34,37 @@ export const OperationListItem = ({
30
34
  return (
31
35
  <div
32
36
  key={operation.operationId}
33
- className="grid grid-cols-1 lg:grid-cols-[4fr_3fr] gap-8 items-start border-b-2 mb-16 pb-16"
37
+ className="grid grid-cols-1 lg:grid-cols-[minmax(0,4fr)_minmax(0,3fr)] gap-8 items-start border-b-2 mb-16 pb-16"
34
38
  >
35
39
  <div className="flex flex-col gap-4">
36
40
  <Heading level={2} id={operation.slug} registerSidebarAnchor>
37
41
  {operation.summary}
38
42
  </Heading>
43
+ <div className="text-sm flex gap-2 font-mono">
44
+ <span className={methodForColor(operation.method)}>
45
+ {operation.method.toUpperCase()}
46
+ </span>
47
+ <div
48
+ ref={parentRef}
49
+ className="max-w-full truncate flex cursor-pointer"
50
+ onClick={() => {
51
+ if (parentRef.current) {
52
+ const range = document.createRange();
53
+ range.selectNodeContents(parentRef.current);
54
+ const selection = window.getSelection();
55
+ selection?.removeAllRanges();
56
+ selection?.addRange(range);
57
+ }
58
+ }}
59
+ >
60
+ <div className="text-neutral-400 dark:text-neutral-500 truncate">
61
+ {serverUrl}
62
+ </div>
63
+ <div className="text-neutral-900 dark:text-neutral-200">
64
+ {operation.path}
65
+ </div>
66
+ </div>
67
+ </div>
39
68
  {operation.description && (
40
69
  <Markdown
41
70
  className={`${ProseClasses} max-w-full prose-img:max-w-prose`}
@@ -3,7 +3,6 @@ import { HTTPSnippet } from "@zudoku/httpsnippet";
3
3
  import { Fragment, useMemo, useTransition } from "react";
4
4
  import { useSearchParams } from "react-router";
5
5
  import { useSelectedServerStore } from "../../authentication/state.js";
6
- import { TextColorMap } from "../../components/navigation/SidebarBadge.js";
7
6
  import { SyntaxHighlight } from "../../components/SyntaxHighlight.js";
8
7
  import type { SchemaObject } from "../../oas/parser/index.js";
9
8
  import { cn } from "../../util/cn.js";
@@ -20,6 +19,7 @@ import { ResponsesSidecarBox } from "./ResponsesSidecarBox.js";
20
19
  import * as SidecarBox from "./SidecarBox.js";
21
20
  import { SimpleSelect } from "./SimpleSelect.js";
22
21
  import { generateSchemaExample } from "./util/generateSchemaExample.js";
22
+ import { methodForColor } from "./util/methodToColor.js";
23
23
 
24
24
  const getConverted = (snippet: HTTPSnippet, option: string) => {
25
25
  let converted;
@@ -76,17 +76,6 @@ export const GetServerQuery = graphql(/* GraphQL */ `
76
76
  }
77
77
  `);
78
78
 
79
- const methodToColor = {
80
- get: TextColorMap.green,
81
- post: TextColorMap.blue,
82
- put: TextColorMap.yellow,
83
- delete: TextColorMap.red,
84
- patch: TextColorMap.purple,
85
- options: TextColorMap.indigo,
86
- head: TextColorMap.gray,
87
- trace: TextColorMap.gray,
88
- };
89
-
90
79
  const EXAMPLE_LANGUAGES = [
91
80
  { value: "shell", label: "cURL" },
92
81
  { value: "js", label: "JavaScript" },
@@ -114,10 +103,7 @@ export const Sidecar = ({
114
103
  const query = useCreateQuery(GetServerQuery, { input, type });
115
104
  const result = useSuspenseQuery(query);
116
105
 
117
- const methodTextColor =
118
- methodToColor[
119
- operation.method.toLocaleLowerCase() as keyof typeof methodToColor
120
- ] ?? TextColorMap.gray;
106
+ const methodTextColor = methodForColor(operation.method);
121
107
 
122
108
  const [searchParams, setSearchParams] = useSearchParams();
123
109
  const [, startTransition] = useTransition();
@@ -0,0 +1,27 @@
1
+ export const TextColorMap = {
2
+ green: "text-green-600",
3
+ blue: "text-sky-600",
4
+ yellow: "text-yellow-600",
5
+ red: "text-red-600",
6
+ purple: "text-purple-600",
7
+ indigo: "text-indigo-600",
8
+ gray: "text-gray-600",
9
+ };
10
+
11
+ export const methodToColor = {
12
+ get: TextColorMap.green,
13
+ post: TextColorMap.blue,
14
+ put: TextColorMap.yellow,
15
+ delete: TextColorMap.red,
16
+ patch: TextColorMap.purple,
17
+ options: TextColorMap.indigo,
18
+ head: TextColorMap.gray,
19
+ trace: TextColorMap.gray,
20
+ };
21
+
22
+ export const methodForColor = (method: string) => {
23
+ return (
24
+ methodToColor[method.toLocaleLowerCase() as keyof typeof methodToColor] ??
25
+ TextColorMap.gray
26
+ );
27
+ };