zudoku 0.46.1 → 0.46.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/dist/config/validators/InputSidebarSchema.d.ts +3 -0
  2. package/dist/config/validators/InputSidebarSchema.js +1 -0
  3. package/dist/config/validators/InputSidebarSchema.js.map +1 -1
  4. package/dist/config/validators/SidebarSchema.d.ts +1 -1
  5. package/dist/config/validators/validate.d.ts +12 -12
  6. package/dist/config/validators/validate.js +3 -1
  7. package/dist/config/validators/validate.js.map +1 -1
  8. package/dist/lib/authentication/AuthenticationPlugin.d.ts +0 -5
  9. package/dist/lib/authentication/AuthenticationPlugin.js +0 -12
  10. package/dist/lib/authentication/AuthenticationPlugin.js.map +1 -1
  11. package/dist/lib/components/navigation/SidebarItem.js +2 -3
  12. package/dist/lib/components/navigation/SidebarItem.js.map +1 -1
  13. package/dist/lib/plugins/api-keys/SettingsApiKeys.js +110 -15
  14. package/dist/lib/plugins/api-keys/SettingsApiKeys.js.map +1 -1
  15. package/dist/lib/plugins/api-keys/index.d.ts +3 -3
  16. package/dist/lib/plugins/api-keys/index.js +14 -14
  17. package/dist/lib/plugins/api-keys/index.js.map +1 -1
  18. package/dist/lib/plugins/openapi/Sidecar.js +11 -91
  19. package/dist/lib/plugins/openapi/Sidecar.js.map +1 -1
  20. package/dist/lib/plugins/openapi/playground/BodyPanel.d.ts +5 -0
  21. package/dist/lib/plugins/openapi/playground/BodyPanel.js +22 -0
  22. package/dist/lib/plugins/openapi/playground/BodyPanel.js.map +1 -0
  23. package/dist/lib/plugins/openapi/playground/ExamplesDropdown.js +2 -1
  24. package/dist/lib/plugins/openapi/playground/ExamplesDropdown.js.map +1 -1
  25. package/dist/lib/plugins/openapi/playground/Headers.js +25 -25
  26. package/dist/lib/plugins/openapi/playground/Headers.js.map +1 -1
  27. package/dist/lib/plugins/openapi/playground/IdentitySelector.js +1 -1
  28. package/dist/lib/plugins/openapi/playground/IdentitySelector.js.map +1 -1
  29. package/dist/lib/plugins/openapi/playground/ParamsGrid.js +2 -2
  30. package/dist/lib/plugins/openapi/playground/ParamsGrid.js.map +1 -1
  31. package/dist/lib/plugins/openapi/playground/PathParams.js +1 -1
  32. package/dist/lib/plugins/openapi/playground/PathParams.js.map +1 -1
  33. package/dist/lib/plugins/openapi/playground/Playground.d.ts +3 -8
  34. package/dist/lib/plugins/openapi/playground/Playground.js +70 -65
  35. package/dist/lib/plugins/openapi/playground/Playground.js.map +1 -1
  36. package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js +1 -1
  37. package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js.map +1 -1
  38. package/dist/lib/plugins/openapi/playground/QueryParams.js +1 -1
  39. package/dist/lib/plugins/openapi/playground/QueryParams.js.map +1 -1
  40. package/dist/lib/plugins/openapi/playground/fileUtils.d.ts +2 -0
  41. package/dist/lib/plugins/openapi/playground/fileUtils.js +22 -0
  42. package/dist/lib/plugins/openapi/playground/fileUtils.js.map +1 -0
  43. package/dist/lib/plugins/openapi/playground/result-panel/ResponseTab.d.ts +4 -1
  44. package/dist/lib/plugins/openapi/playground/result-panel/ResponseTab.js +29 -20
  45. package/dist/lib/plugins/openapi/playground/result-panel/ResponseTab.js.map +1 -1
  46. package/dist/lib/plugins/openapi/playground/result-panel/ResultPanel.js +2 -2
  47. package/dist/lib/plugins/openapi/playground/result-panel/ResultPanel.js.map +1 -1
  48. package/dist/lib/plugins/openapi/playground/useRememberSkipLoginDialog.d.ts +16 -0
  49. package/dist/lib/plugins/openapi/playground/useRememberSkipLoginDialog.js +10 -0
  50. package/dist/lib/plugins/openapi/playground/useRememberSkipLoginDialog.js.map +1 -0
  51. package/dist/lib/plugins/openapi/util/createHttpSnippet.d.ts +11 -0
  52. package/dist/lib/plugins/openapi/util/createHttpSnippet.js +89 -0
  53. package/dist/lib/plugins/openapi/util/createHttpSnippet.js.map +1 -0
  54. package/dist/lib/shiki.d.ts +8 -12
  55. package/dist/lib/shiki.js +11 -13
  56. package/dist/lib/shiki.js.map +1 -1
  57. package/dist/lib/ui/CodeBlock.js +1 -1
  58. package/dist/lib/ui/CodeBlock.js.map +1 -1
  59. package/dist/lib/ui/Dialog.d.ts +3 -1
  60. package/dist/lib/ui/Dialog.js +2 -2
  61. package/dist/lib/ui/Dialog.js.map +1 -1
  62. package/dist/lib/util/humanFileSize.d.ts +6 -0
  63. package/dist/lib/util/humanFileSize.js +14 -0
  64. package/dist/lib/util/humanFileSize.js.map +1 -0
  65. package/dist/lib/util/humanFileSize.test.d.ts +1 -0
  66. package/dist/lib/util/humanFileSize.test.js +22 -0
  67. package/dist/lib/util/humanFileSize.test.js.map +1 -0
  68. package/dist/vite/build.js +1 -4
  69. package/dist/vite/build.js.map +1 -1
  70. package/lib/{Callout-BkgOUkoZ.js → Callout-CoVxYafP.js} +2 -2
  71. package/lib/{Callout-BkgOUkoZ.js.map → Callout-CoVxYafP.js.map} +1 -1
  72. package/lib/{Dialog-Du6WMcIA.js → Dialog-BxpuVLh9.js} +25 -25
  73. package/lib/Dialog-BxpuVLh9.js.map +1 -0
  74. package/lib/{Markdown-BRAyzyUJ.js → Markdown-D81l28Ib.js} +310 -306
  75. package/lib/{Markdown-BRAyzyUJ.js.map → Markdown-D81l28Ib.js.map} +1 -1
  76. package/lib/{MdxPage-B3v1BSKr.js → MdxPage-S_CxlNmX.js} +5 -5
  77. package/lib/{MdxPage-B3v1BSKr.js.map → MdxPage-S_CxlNmX.js.map} +1 -1
  78. package/lib/{OasProvider-5jrFuhVk.js → OasProvider-D5rt6WMb.js} +3 -3
  79. package/lib/{OasProvider-5jrFuhVk.js.map → OasProvider-D5rt6WMb.js.map} +1 -1
  80. package/lib/{OperationList-BmoMLQPO.js → OperationList-CNhg654C.js} +1139 -1131
  81. package/lib/OperationList-CNhg654C.js.map +1 -0
  82. package/lib/{Pagination-Cr0fWZS3.js → Pagination-CCxhL836.js} +2 -2
  83. package/lib/{Pagination-Cr0fWZS3.js.map → Pagination-CCxhL836.js.map} +1 -1
  84. package/lib/{RouteGuard-PrSVLbSr.js → RouteGuard-CZ_uLv3g.js} +6 -6
  85. package/lib/{RouteGuard-PrSVLbSr.js.map → RouteGuard-CZ_uLv3g.js.map} +1 -1
  86. package/lib/{SchemaList-B4riYLoP.js → SchemaList-BvzCrTYg.js} +6 -6
  87. package/lib/{SchemaList-B4riYLoP.js.map → SchemaList-BvzCrTYg.js.map} +1 -1
  88. package/lib/{SchemaView-CPZ6RgsF.js → SchemaView-Br1RupCp.js} +3 -3
  89. package/lib/{SchemaView-CPZ6RgsF.js.map → SchemaView-Br1RupCp.js.map} +1 -1
  90. package/lib/{SignUp-CWaiH0tY.js → SignUp-B-1Pvc-8.js} +3 -3
  91. package/lib/{SignUp-CWaiH0tY.js.map → SignUp-B-1Pvc-8.js.map} +1 -1
  92. package/lib/{Slot-Bo6K4tnb.js → Slot-T8NJUkm4.js} +11 -11
  93. package/lib/{Slot-Bo6K4tnb.js.map → Slot-T8NJUkm4.js.map} +1 -1
  94. package/lib/{SyntaxHighlight-DedRjJNr.js → SyntaxHighlight-Cz6Me7-F.js} +4474 -3323
  95. package/lib/SyntaxHighlight-Cz6Me7-F.js.map +1 -0
  96. package/lib/{Toc-lL3fzNkl.js → Toc-PA-j0gEu.js} +2 -2
  97. package/lib/{Toc-lL3fzNkl.js.map → Toc-PA-j0gEu.js.map} +1 -1
  98. package/lib/{chunk-BAXFHI7N-C9WnHsLV.js → chunk-DQRVZFIR-BblmKnHy.js} +697 -697
  99. package/lib/chunk-DQRVZFIR-BblmKnHy.js.map +1 -0
  100. package/lib/{circular-oB4auIIg.js → circular-5FeDWJOn.js} +1812 -1807
  101. package/lib/circular-5FeDWJOn.js.map +1 -0
  102. package/lib/{createServer-DCB82j2t.js → createServer-BC2RZgmW.js} +3648 -3493
  103. package/lib/createServer-BC2RZgmW.js.map +1 -0
  104. package/lib/{hook-DawSLaZr.js → hook-k7PfUIsj.js} +10 -10
  105. package/lib/{hook-DawSLaZr.js.map → hook-k7PfUIsj.js.map} +1 -1
  106. package/lib/{index-BXYvD5-7.js → index-CJZthJSj.js} +1053 -1095
  107. package/lib/index-CJZthJSj.js.map +1 -0
  108. package/lib/index.esm-Cp4wkyud.js +1236 -0
  109. package/lib/index.esm-Cp4wkyud.js.map +1 -0
  110. package/lib/{mutation-oxMvODNQ.js → mutation-BSeQ8pEK.js} +2 -2
  111. package/lib/{mutation-oxMvODNQ.js.map → mutation-BSeQ8pEK.js.map} +1 -1
  112. package/lib/react-nprogress.esm-C2MPXjiJ.js +389 -0
  113. package/lib/react-nprogress.esm-C2MPXjiJ.js.map +1 -0
  114. package/lib/ui/CodeBlock.js +17 -16
  115. package/lib/ui/CodeBlock.js.map +1 -1
  116. package/lib/ui/Command.js +1 -1
  117. package/lib/ui/Dialog.js +25 -25
  118. package/lib/ui/Dialog.js.map +1 -1
  119. package/lib/ui/Form.js +1 -1
  120. package/lib/ui/SyntaxHighlight.js +2 -2
  121. package/lib/{useExposedProps-DG8J6ewJ.js → useExposedProps-BZQkZneR.js} +2 -2
  122. package/lib/{useExposedProps-DG8J6ewJ.js.map → useExposedProps-BZQkZneR.js.map} +1 -1
  123. package/lib/{useMutation-C_j3dA_L.js → useMutation-CZSmsIGW.js} +3 -3
  124. package/lib/{useMutation-C_j3dA_L.js.map → useMutation-CZSmsIGW.js.map} +1 -1
  125. package/lib/zudoku.auth-auth0.js +1 -1
  126. package/lib/zudoku.auth-clerk.js +2 -2
  127. package/lib/zudoku.auth-openid.js +57 -66
  128. package/lib/zudoku.auth-openid.js.map +1 -1
  129. package/lib/zudoku.components.js +1698 -2082
  130. package/lib/zudoku.components.js.map +1 -1
  131. package/lib/zudoku.hooks.js +11 -11
  132. package/lib/zudoku.plugin-api-catalog.js +5 -5
  133. package/lib/zudoku.plugin-api-keys.js +473 -4970
  134. package/lib/zudoku.plugin-api-keys.js.map +1 -1
  135. package/lib/zudoku.plugin-custom-pages.js +2 -2
  136. package/lib/zudoku.plugin-markdown.js +1 -1
  137. package/lib/zudoku.plugin-openapi.js +3 -3
  138. package/lib/zudoku.plugin-redirect.js +1 -1
  139. package/lib/zudoku.plugin-search-pagefind.js +5 -5
  140. package/package.json +33 -34
  141. package/src/lib/authentication/AuthenticationPlugin.tsx +0 -14
  142. package/src/lib/components/navigation/SidebarItem.tsx +2 -1
  143. package/src/lib/plugins/api-keys/SettingsApiKeys.tsx +193 -48
  144. package/src/lib/plugins/api-keys/index.tsx +25 -18
  145. package/src/lib/plugins/openapi/Sidecar.tsx +11 -97
  146. package/src/lib/plugins/openapi/playground/BodyPanel.tsx +46 -0
  147. package/src/lib/plugins/openapi/playground/ExamplesDropdown.tsx +4 -1
  148. package/src/lib/plugins/openapi/playground/Headers.tsx +110 -106
  149. package/src/lib/plugins/openapi/playground/IdentitySelector.tsx +13 -11
  150. package/src/lib/plugins/openapi/playground/ParamsGrid.tsx +2 -2
  151. package/src/lib/plugins/openapi/playground/PathParams.tsx +1 -1
  152. package/src/lib/plugins/openapi/playground/Playground.tsx +127 -211
  153. package/src/lib/plugins/openapi/playground/PlaygroundDialog.tsx +2 -1
  154. package/src/lib/plugins/openapi/playground/QueryParams.tsx +1 -1
  155. package/src/lib/plugins/openapi/playground/fileUtils.ts +32 -0
  156. package/src/lib/plugins/openapi/playground/result-panel/ResponseTab.tsx +74 -39
  157. package/src/lib/plugins/openapi/playground/result-panel/ResultPanel.tsx +4 -1
  158. package/src/lib/plugins/openapi/playground/useRememberSkipLoginDialog.tsx +20 -0
  159. package/src/lib/plugins/openapi/util/createHttpSnippet.ts +107 -0
  160. package/src/lib/shiki.ts +21 -22
  161. package/src/lib/ui/CodeBlock.tsx +1 -0
  162. package/src/lib/ui/Dialog.tsx +11 -7
  163. package/src/lib/util/humanFileSize.test.ts +24 -0
  164. package/src/lib/util/humanFileSize.ts +16 -0
  165. package/dist/lib/plugins/openapi/playground/SubmitButton.d.ts +0 -7
  166. package/dist/lib/plugins/openapi/playground/SubmitButton.js +0 -19
  167. package/dist/lib/plugins/openapi/playground/SubmitButton.js.map +0 -1
  168. package/lib/Dialog-Du6WMcIA.js.map +0 -1
  169. package/lib/OperationList-BmoMLQPO.js.map +0 -1
  170. package/lib/SyntaxHighlight-DedRjJNr.js.map +0 -1
  171. package/lib/chunk-BAXFHI7N-C9WnHsLV.js.map +0 -1
  172. package/lib/circular-oB4auIIg.js.map +0 -1
  173. package/lib/createServer-DCB82j2t.js.map +0 -1
  174. package/lib/index-BXYvD5-7.js.map +0 -1
  175. package/lib/index.esm-DSfX_eMP.js +0 -1216
  176. package/lib/index.esm-DSfX_eMP.js.map +0 -1
  177. package/src/lib/plugins/openapi/playground/SubmitButton.tsx +0 -70
@@ -1,8 +1,7 @@
1
1
  import { useSuspenseQuery } from "@tanstack/react-query";
2
- import { HTTPSnippet } from "@zudoku/httpsnippet";
3
2
  import { useMemo, useState, useTransition } from "react";
4
3
  import { useSearchParams } from "react-router";
5
- import { useZudoku } from "zudoku/components";
4
+ import { useZudoku } from "zudoku/hooks";
6
5
  import { useAuthState } from "../../authentication/state.js";
7
6
  import { PathRenderer } from "../../components/PathRenderer.js";
8
7
  import type { SchemaObject } from "../../oas/parser/index.js";
@@ -21,53 +20,10 @@ import { ResponsesSidecarBox } from "./ResponsesSidecarBox.js";
21
20
  import * as SidecarBox from "./SidecarBox.js";
22
21
  import { SimpleSelect } from "./SimpleSelect.js";
23
22
  import { useSelectedServer } from "./state.js";
23
+ import { createHttpSnippet, getConverted } from "./util/createHttpSnippet.js";
24
24
  import { generateSchemaExample } from "./util/generateSchemaExample.js";
25
25
  import { methodForColor } from "./util/methodToColor.js";
26
26
 
27
- const getConverted = (snippet: HTTPSnippet, option: string) => {
28
- let converted;
29
- switch (option) {
30
- case "shell":
31
- converted = snippet.convert("shell", "curl");
32
- break;
33
- case "js":
34
- converted = snippet.convert("javascript", "fetch");
35
- break;
36
- case "python":
37
- converted = snippet.convert("python", "requests");
38
- break;
39
- case "java":
40
- converted = snippet.convert("java", "okhttp");
41
- break;
42
- case "go":
43
- converted = snippet.convert("go", "native");
44
- break;
45
- case "csharp":
46
- converted = snippet.convert("csharp", "httpclient");
47
- break;
48
- case "kotlin":
49
- converted = snippet.convert("kotlin", "okhttp");
50
- break;
51
- case "objc":
52
- converted = snippet.convert("objc", "nsurlsession");
53
- break;
54
- case "php":
55
- converted = snippet.convert("php", "http2");
56
- break;
57
- case "ruby":
58
- converted = snippet.convert("ruby");
59
- break;
60
- case "swift":
61
- converted = snippet.convert("swift");
62
- break;
63
- default:
64
- converted = snippet.convert("shell");
65
- break;
66
- }
67
-
68
- return converted ? converted[0] : "";
69
- };
70
-
71
27
  export const GetServerQuery = graphql(/* GraphQL */ `
72
28
  query getServerQuery($input: JSON!, $type: SchemaType!) {
73
29
  schema(input: $input, type: $type) {
@@ -149,7 +105,7 @@ export const Sidecar = ({
149
105
  const { selectedServer } = useSelectedServer(result.data.schema.servers);
150
106
 
151
107
  const code = useMemo(() => {
152
- const example =
108
+ const exampleBody =
153
109
  selectedExample ??
154
110
  (transformedRequestBodyContent?.[0]?.schema
155
111
  ? generateSchemaExample(
@@ -157,66 +113,24 @@ export const Sidecar = ({
157
113
  )
158
114
  : undefined);
159
115
 
160
- const snippet = new HTTPSnippet({
161
- method: operation.method.toLocaleUpperCase(),
162
- url:
163
- selectedServer +
164
- operation.path.replaceAll("{", ":").replaceAll("}", ""),
165
- postData: example
116
+ const snippet = createHttpSnippet({
117
+ operation,
118
+ selectedServer,
119
+ exampleBody: exampleBody
166
120
  ? {
167
- text: JSON.stringify(example, null, 2),
168
121
  mimeType: "application/json",
122
+ text: JSON.stringify(exampleBody, null, 2),
169
123
  }
170
- : ({} as any),
171
- headers: [
172
- { name: "Content-Type", value: "application/json" },
173
- ...(operation.parameters
174
- ?.filter((p) => p.in === "header" && p.required === true)
175
- .map((p) => ({
176
- name: p.name,
177
- value:
178
- p.examples?.find((x) => x.value)?.value ??
179
- p.schema?.default ??
180
- (p.schema?.type === "string"
181
- ? "string"
182
- : p.schema?.type === "number" || p.schema?.type === "integer"
183
- ? "0"
184
- : p.schema?.type === "boolean"
185
- ? "true"
186
- : ""),
187
- })) ?? []),
188
- ],
189
- queryString:
190
- operation.parameters
191
- ?.filter((p) => p.in === "query" && p.required === true)
192
- .map((p) => ({
193
- name: p.name,
194
- value:
195
- p.examples?.find((x) => x.value)?.value ??
196
- p.schema?.default ??
197
- (p.schema?.type === "string"
198
- ? "string"
199
- : p.schema?.type === "number" || p.schema?.type === "integer"
200
- ? "0"
201
- : p.schema?.type === "boolean"
202
- ? "true"
203
- : ""),
204
- })) ?? [],
205
- httpVersion: "",
206
- cookies: [],
207
- headersSize: 0,
208
- bodySize: 0,
124
+ : { mimeType: "application/json" },
209
125
  });
210
126
 
211
127
  return getConverted(snippet, selectedLang);
212
128
  }, [
213
129
  selectedExample,
214
130
  transformedRequestBodyContent,
215
- operation.method,
216
- operation.path,
131
+ operation,
217
132
  selectedServer,
218
133
  selectedLang,
219
- operation.parameters,
220
134
  ]);
221
135
  const [ref, isOnScreen] = useOnScreen({ rootMargin: "200px 0px 200px 0px" });
222
136
 
@@ -238,7 +152,7 @@ export const Sidecar = ({
238
152
  <SidecarBox.Head className="flex justify-between items-center flex-nowrap py-2.5 gap-2 text-xs">
239
153
  <span className="font-mono break-words leading-6">
240
154
  <span className={cn("font-semibold", methodTextColor)}>
241
- {operation.method.toLocaleUpperCase()}
155
+ {operation.method.toUpperCase()}
242
156
  </span>
243
157
  &nbsp;
244
158
  {path}
@@ -0,0 +1,46 @@
1
+ import { useFormContext } from "react-hook-form";
2
+ import { Textarea } from "zudoku/ui/Textarea.js";
3
+ import { cn } from "../../../util/cn.js";
4
+ import { type Content } from "../SidecarExamples.js";
5
+ import ExamplesDropdown from "./ExamplesDropdown.js";
6
+ import { type PlaygroundForm } from "./Playground.js";
7
+
8
+ export const BodyPanel = ({ examples }: { examples?: Content }) => {
9
+ const { register, setValue, watch } = useFormContext<PlaygroundForm>();
10
+
11
+ const headers = watch("headers");
12
+
13
+ return (
14
+ <div className="flex flex-col gap-2 ">
15
+ <div className="flex justify-between gap-2">
16
+ <span className="font-semibold">Body</span>
17
+ <div className="flex flex-col gap-2">
18
+ {examples && examples.length > 0 && (
19
+ <ExamplesDropdown
20
+ examples={examples}
21
+ onSelect={(example, mediaType) => {
22
+ setValue("body", JSON.stringify(example.value, null, 2));
23
+ setValue("headers", [
24
+ ...headers.filter((h) => h.name !== "Content-Type"),
25
+ {
26
+ name: "Content-Type",
27
+ value: mediaType,
28
+ active: true,
29
+ },
30
+ ]);
31
+ }}
32
+ />
33
+ )}
34
+ </div>
35
+ </div>
36
+ <Textarea
37
+ {...register("body")}
38
+ className={cn(
39
+ "border w-full rounded-lg bg-muted/40 p-2 h-64 font-mono text-[13px]",
40
+ )}
41
+ />
42
+ </div>
43
+ );
44
+ };
45
+
46
+ export default BodyPanel;
@@ -1,3 +1,4 @@
1
+ import { ChevronDownIcon } from "lucide-react";
1
2
  import { Button } from "zudoku/ui/Button.js";
2
3
  import {
3
4
  DropdownMenu,
@@ -20,7 +21,9 @@ const ExamplesDropdown = ({
20
21
  return (
21
22
  <DropdownMenu>
22
23
  <DropdownMenuTrigger asChild>
23
- <Button variant="outline">Use Example</Button>
24
+ <Button variant="ghost" size="sm">
25
+ Use Example <ChevronDownIcon className="w-4 h-4" />
26
+ </Button>
24
27
  </DropdownMenuTrigger>
25
28
  <DropdownMenuContent className="max-w-72">
26
29
  {examples.map((mediaTypeObject) => (
@@ -83,119 +83,123 @@ export const Headers = ({
83
83
  .map(({ name }) => name);
84
84
 
85
85
  return (
86
- <div className="flex flex-col gap-2">
87
- <Card className="overflow-hidden">
88
- <ParamsGrid>
89
- {fields.map((field, i) => {
90
- const currentHeader = schemaHeaders.find(
91
- (h) => h.name === watch(`headers.${i}.name`),
92
- );
93
- return (
94
- <ParamsGridItem key={field.id}>
95
- <div className="flex items-center gap-2 ">
96
- <Controller
97
- control={control}
98
- name={`headers.${i}.active`}
99
- render={({ field }) => (
100
- <Checkbox
101
- id={`headers.${i}.active`}
102
- checked={field.value}
103
- onCheckedChange={(checked) => {
104
- field.onChange(checked);
105
- }}
106
- />
107
- )}
108
- />
109
- <Controller
110
- control={control}
111
- name={`headers.${i}.name`}
112
- render={({ field }) => (
113
- <Autocomplete
114
- {...field}
115
- placeholder="Name"
116
- className="border-0 shadow-none focus-visible:ring-0 bg-transparent hover:bg-transparent text-xs font-mono"
117
- options={[...missingHeaders, ...headerOptions]}
118
- onEnterPress={() => handleHeaderEnter(i)}
119
- onChange={(e) => {
120
- field.onChange(e);
121
- setValue(`headers.${i}.active`, true);
122
- }}
123
- ref={(el) => {
124
- nameRefs.current[i] = el;
125
- }}
126
- />
127
- )}
128
- />
129
- </div>
130
- <div className="flex items-center gap-2">
131
- <Controller
132
- control={control}
133
- name={`headers.${i}.value`}
134
- render={({ field }) => {
135
- const hasEnum =
136
- currentHeader?.enum && currentHeader.enum.length > 0;
137
-
138
- if (!hasEnum) {
139
- return (
140
- <Input
141
- placeholder="Value"
142
- className="w-full border-0 shadow-none text-xs font-mono focus-visible:ring-0"
143
- {...field}
144
- ref={(el) => {
145
- valueRefs.current[i] = el;
146
- }}
147
- onKeyDown={(e) => {
148
- if (
149
- e.key === "Enter" &&
150
- e.currentTarget.value.trim()
151
- ) {
152
- handleValueEnter(i);
153
- }
154
- }}
155
- autoComplete="off"
156
- />
157
- );
158
- }
159
-
160
- return (
161
- <Autocomplete
162
- shouldFilter={false}
163
- value={field.value}
164
- options={currentHeader.enum ?? []}
165
- onChange={(e) => {
166
- field.onChange(e);
167
- setValue(`headers.${i}.active`, true);
168
- }}
169
- className="border-0 shadow-none focus-visible:ring-0 bg-transparent hover:bg-transparent text-xs font-mono"
170
- />
171
- );
172
- }}
173
- />
174
- <Button
175
- size="icon"
176
- variant="ghost"
177
- className="text-muted-foreground opacity-0 group-hover:opacity-100 rounded-full w-8 h-7"
178
- onClick={() => remove(i)}
179
- type="button"
180
- >
181
- <XIcon size={16} />
182
- </Button>
183
- </div>
184
- </ParamsGridItem>
185
- );
186
- })}
187
- </ParamsGrid>
188
- </Card>
189
- <div className="text-end">
86
+ <div className="flex flex-col gap-2 ">
87
+ <div className="flex items-center justify-between">
88
+ <span className="font-semibold">Headers</span>
190
89
  <Button
191
90
  className=""
192
91
  onClick={addNewHeader}
193
92
  type="button"
194
- variant="secondary"
93
+ size="sm"
94
+ variant="ghost"
195
95
  >
196
- Add header
96
+ + Add header
197
97
  </Button>
198
98
  </div>
99
+ <div className="flex flex-col gap-2">
100
+ <Card className="overflow-hidden rounded-lg">
101
+ <ParamsGrid>
102
+ {fields.map((field, i) => {
103
+ const currentHeader = schemaHeaders.find(
104
+ (h) => h.name === watch(`headers.${i}.name`),
105
+ );
106
+ return (
107
+ <ParamsGridItem key={field.id}>
108
+ <div className="flex items-center gap-2 ">
109
+ <Controller
110
+ control={control}
111
+ name={`headers.${i}.active`}
112
+ render={({ field }) => (
113
+ <Checkbox
114
+ id={`headers.${i}.active`}
115
+ checked={field.value}
116
+ onCheckedChange={(checked) => {
117
+ field.onChange(checked);
118
+ }}
119
+ />
120
+ )}
121
+ />
122
+ <Controller
123
+ control={control}
124
+ name={`headers.${i}.name`}
125
+ render={({ field }) => (
126
+ <Autocomplete
127
+ {...field}
128
+ placeholder="Name"
129
+ className="border-0 shadow-none focus-visible:ring-0 bg-transparent hover:bg-transparent text-xs font-mono"
130
+ options={[...missingHeaders, ...headerOptions]}
131
+ onEnterPress={() => handleHeaderEnter(i)}
132
+ onChange={(e) => {
133
+ field.onChange(e);
134
+ setValue(`headers.${i}.active`, true);
135
+ }}
136
+ ref={(el) => {
137
+ nameRefs.current[i] = el;
138
+ }}
139
+ />
140
+ )}
141
+ />
142
+ </div>
143
+ <div className="flex items-center gap-2">
144
+ <Controller
145
+ control={control}
146
+ name={`headers.${i}.value`}
147
+ render={({ field }) => {
148
+ const hasEnum =
149
+ currentHeader?.enum && currentHeader.enum.length > 0;
150
+
151
+ if (!hasEnum) {
152
+ return (
153
+ <Input
154
+ placeholder="Value"
155
+ className="w-full border-0 shadow-none text-xs font-mono focus-visible:ring-0"
156
+ {...field}
157
+ ref={(el) => {
158
+ valueRefs.current[i] = el;
159
+ }}
160
+ onKeyDown={(e) => {
161
+ if (
162
+ e.key === "Enter" &&
163
+ e.currentTarget.value.trim()
164
+ ) {
165
+ handleValueEnter(i);
166
+ }
167
+ }}
168
+ autoComplete="off"
169
+ />
170
+ );
171
+ }
172
+
173
+ return (
174
+ <Autocomplete
175
+ shouldFilter={false}
176
+ value={field.value}
177
+ options={currentHeader.enum ?? []}
178
+ onChange={(e) => {
179
+ field.onChange(e);
180
+ setValue(`headers.${i}.active`, true);
181
+ }}
182
+ className="border-0 shadow-none focus-visible:ring-0 bg-transparent hover:bg-transparent text-xs font-mono"
183
+ />
184
+ );
185
+ }}
186
+ />
187
+ <Button
188
+ size="icon"
189
+ variant="ghost"
190
+ className="text-muted-foreground opacity-0 group-hover:opacity-100 rounded-full w-8 h-7"
191
+ onClick={() => remove(i)}
192
+ type="button"
193
+ >
194
+ <XIcon size={16} />
195
+ </Button>
196
+ </div>
197
+ </ParamsGridItem>
198
+ );
199
+ })}
200
+ </ParamsGrid>
201
+ </Card>
202
+ </div>
199
203
  </div>
200
204
  );
201
205
  };
@@ -13,7 +13,7 @@ const IdentitySelector = ({
13
13
  setValue: (value: string) => void;
14
14
  value?: string;
15
15
  }) => (
16
- <Card className="w-full overflow-hidden">
16
+ <Card className="w-full overflow-hidden rounded-lg">
17
17
  <RadioGroup
18
18
  onValueChange={(value) => setValue(value)}
19
19
  value={value}
@@ -21,19 +21,21 @@ const IdentitySelector = ({
21
21
  className="gap-0"
22
22
  disabled={identities?.length === 0}
23
23
  >
24
- <Label className="h-12 border-b items-center flex gap-2 p-4 cursor-pointer hover:bg-accent">
24
+ <Label className="h-10 border-b items-center flex gap-2 p-4 cursor-pointer hover:bg-accent">
25
25
  <RadioGroupItem value={NO_IDENTITY} id="none" />
26
26
  <span>None</span>
27
27
  </Label>
28
- {identities?.map((identity) => (
29
- <Label
30
- key={identity.id}
31
- className="h-12 border-b items-center flex gap-2 p-4 cursor-pointer hover:bg-accent"
32
- >
33
- <RadioGroupItem value={identity.id} id={identity.id} />
34
- <span>{identity.label}</span>
35
- </Label>
36
- ))}
28
+ <div className="divide-y">
29
+ {identities?.map((identity) => (
30
+ <Label
31
+ key={identity.id}
32
+ className="h-10 items-center flex gap-2 p-4 cursor-pointer hover:bg-accent"
33
+ >
34
+ <RadioGroupItem value={identity.id} id={identity.id} />
35
+ <span>{identity.label}</span>
36
+ </Label>
37
+ ))}
38
+ </div>
37
39
  </RadioGroup>
38
40
  </Card>
39
41
  );
@@ -2,12 +2,12 @@ import createVariantComponent from "../../../util/createVariantComponent.js";
2
2
 
3
3
  const ParamsGrid = createVariantComponent(
4
4
  "div",
5
- "grid grid-cols-[2fr_3fr] gap-2 items-center",
5
+ "grid grid-cols-[2fr_3fr] items-center",
6
6
  );
7
7
 
8
8
  export const ParamsGridItem = createVariantComponent(
9
9
  "div",
10
- "group hover:bg-accent px-3 grid col-span-full grid-cols-subgrid",
10
+ "group hover:bg-accent px-4 py-1 grid col-span-full grid-cols-subgrid",
11
11
  );
12
12
 
13
13
  export default ParamsGrid;
@@ -22,7 +22,7 @@ export const PathParams = ({
22
22
  );
23
23
 
24
24
  return (
25
- <Card className="rounded-lg">
25
+ <Card className="rounded-lg overflow-hidden">
26
26
  <ParamsGrid>
27
27
  {sortedFields.map((field, i) => (
28
28
  <ParamsGridItem key={field.id}>