zudoku 0.3.0-dev.64 → 0.3.0-dev.66

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 (66) hide show
  1. package/dist/lib/components/SyntaxHighlight.js +6 -2
  2. package/dist/lib/components/SyntaxHighlight.js.map +1 -1
  3. package/dist/lib/plugins/api-keys/CreateApiKey.js +1 -1
  4. package/dist/lib/plugins/api-keys/CreateApiKey.js.map +1 -1
  5. package/dist/lib/plugins/openapi/ColorizedParam.d.ts +2 -1
  6. package/dist/lib/plugins/openapi/ColorizedParam.js +13 -8
  7. package/dist/lib/plugins/openapi/ColorizedParam.js.map +1 -1
  8. package/dist/lib/plugins/openapi/ResponsesSidecarBox.js +1 -1
  9. package/dist/lib/plugins/openapi/ResponsesSidecarBox.js.map +1 -1
  10. package/dist/lib/plugins/openapi/Sidecar.js +19 -14
  11. package/dist/lib/plugins/openapi/Sidecar.js.map +1 -1
  12. package/dist/lib/plugins/openapi/SidecarBox.d.ts +1 -0
  13. package/dist/lib/plugins/openapi/SidecarBox.js +2 -1
  14. package/dist/lib/plugins/openapi/SidecarBox.js.map +1 -1
  15. package/dist/lib/plugins/openapi/playground/PathParams.d.ts +1 -1
  16. package/dist/lib/plugins/openapi/playground/PathParams.js +9 -12
  17. package/dist/lib/plugins/openapi/playground/PathParams.js.map +1 -1
  18. package/dist/lib/plugins/openapi/playground/Playground.js +9 -3
  19. package/dist/lib/plugins/openapi/playground/Playground.js.map +1 -1
  20. package/dist/lib/plugins/openapi/playground/QueryParams.d.ts +1 -1
  21. package/dist/lib/plugins/openapi/playground/QueryParams.js +12 -9
  22. package/dist/lib/plugins/openapi/playground/QueryParams.js.map +1 -1
  23. package/dist/lib/ui/Input.js.map +1 -0
  24. package/lib/{AnchorLink-Bj1hwDuD.js → AnchorLink-C_pYhuZi.js} +2 -2
  25. package/lib/{AnchorLink-Bj1hwDuD.js.map → AnchorLink-C_pYhuZi.js.map} +1 -1
  26. package/lib/{CategoryHeading-DMkTmmBh.js → CategoryHeading-D5Q-X6lE.js} +2 -2
  27. package/lib/{CategoryHeading-DMkTmmBh.js.map → CategoryHeading-D5Q-X6lE.js.map} +1 -1
  28. package/lib/{Combination-lAFQBd6U.js → Combination-Cq0UkOXq.js} +2 -2
  29. package/lib/{Combination-lAFQBd6U.js.map → Combination-Cq0UkOXq.js.map} +1 -1
  30. package/lib/{Select-CEnkyfyn.js → Input-DdAxw3vC.js} +263 -247
  31. package/lib/Input-DdAxw3vC.js.map +1 -0
  32. package/lib/{Markdown-BjRJKl_E.js → Markdown-DsCvZnhw.js} +110 -103
  33. package/lib/{Markdown-BjRJKl_E.js.map → Markdown-DsCvZnhw.js.map} +1 -1
  34. package/lib/{MdxPage-BjOLKhCI.js → MdxPage-B_7x36CA.js} +4 -4
  35. package/lib/{MdxPage-BjOLKhCI.js.map → MdxPage-B_7x36CA.js.map} +1 -1
  36. package/lib/{OperationList-DDTtK3I7.js → OperationList-Cv0GStt7.js} +2013 -1954
  37. package/lib/OperationList-Cv0GStt7.js.map +1 -0
  38. package/lib/{Spinner-Ciq_pWU7.js → Spinner-DyDcSKPz.js} +3 -3
  39. package/lib/{Spinner-Ciq_pWU7.js.map → Spinner-DyDcSKPz.js.map} +1 -1
  40. package/lib/{hook-BY1NP0kj.js → hook-Cz5jddRs.js} +4 -4
  41. package/lib/{hook-BY1NP0kj.js.map → hook-Cz5jddRs.js.map} +1 -1
  42. package/lib/{index-BE2a6gGC.js → index-NGns0N9q.js} +4 -4
  43. package/lib/{index-BE2a6gGC.js.map → index-NGns0N9q.js.map} +1 -1
  44. package/lib/zudoku.components.js +5 -5
  45. package/lib/zudoku.plugin-api-keys.js +79 -95
  46. package/lib/zudoku.plugin-api-keys.js.map +1 -1
  47. package/lib/zudoku.plugin-custom-page.js +1 -1
  48. package/lib/zudoku.plugin-markdown.js +1 -1
  49. package/lib/zudoku.plugin-openapi.js +2 -2
  50. package/package.json +1 -1
  51. package/src/app/main.css +2 -2
  52. package/src/lib/components/SyntaxHighlight.tsx +28 -23
  53. package/src/lib/plugins/api-keys/CreateApiKey.tsx +1 -1
  54. package/src/lib/plugins/openapi/ColorizedParam.tsx +22 -15
  55. package/src/lib/plugins/openapi/ResponsesSidecarBox.tsx +3 -4
  56. package/src/lib/plugins/openapi/Sidecar.tsx +30 -23
  57. package/src/lib/plugins/openapi/SidecarBox.tsx +12 -1
  58. package/src/lib/plugins/openapi/playground/PathParams.tsx +79 -47
  59. package/src/lib/plugins/openapi/playground/Playground.tsx +37 -34
  60. package/src/lib/plugins/openapi/playground/QueryParams.tsx +92 -68
  61. package/dist/lib/components/Input.js.map +0 -1
  62. package/lib/OperationList-DDTtK3I7.js.map +0 -1
  63. package/lib/Select-CEnkyfyn.js.map +0 -1
  64. /package/dist/lib/{components → ui}/Input.d.ts +0 -0
  65. /package/dist/lib/{components → ui}/Input.js +0 -0
  66. /package/src/lib/{components → ui}/Input.tsx +0 -0
@@ -2,7 +2,6 @@ import { useMutation } from "@tanstack/react-query";
2
2
  import { useForm } from "react-hook-form";
3
3
  import { Link, useNavigate } from "react-router-dom";
4
4
  import { useDevPortal } from "../../components/context/DevPortalProvider.js";
5
- import { Input } from "../../components/Input.js";
6
5
  import {
7
6
  Select,
8
7
  SelectContent,
@@ -12,6 +11,7 @@ import {
12
11
  SelectValue,
13
12
  } from "../../components/Select.js";
14
13
  import { Button } from "../../ui/Button.js";
14
+ import { Input } from "../../ui/Input.js";
15
15
  import { ApiKeyService } from "./index.js";
16
16
 
17
17
  type CreateApiKey = { description: string; expiresOn?: string };
@@ -9,7 +9,7 @@ export const usePastellizedColor = (name: string) => {
9
9
  const [isDark] = useTheme();
10
10
  return pastellize(
11
11
  name,
12
- !isDark ? { saturation: 100, lightness: 70 } : undefined,
12
+ !isDark ? { saturation: 85, lightness: 50 } : undefined,
13
13
  );
14
14
  };
15
15
 
@@ -17,6 +17,7 @@ export const ColorizedParam = ({
17
17
  name,
18
18
  className,
19
19
  backgroundOpacity = "100%",
20
+ borderOpacity = "100%",
20
21
  slug,
21
22
  children,
22
23
  onClick,
@@ -24,34 +25,40 @@ export const ColorizedParam = ({
24
25
  name: string;
25
26
  className?: string;
26
27
  backgroundOpacity?: string;
28
+ borderOpacity?: string;
27
29
  slug?: string;
28
30
  children?: ReactNode;
29
31
  onClick?: () => void;
30
32
  }) => {
31
33
  const ref = useRef<HTMLSpanElement>(null);
32
34
  const normalized = name.replace("{", "").replace("}", "");
35
+ const normalizedSlug = slug?.replace("{", "").replace("}", "");
33
36
  const color = usePastellizedColor(normalized);
34
37
 
35
- const borderColor = `hsl(${color})`;
38
+ const borderColor = `hsl(${color} / ${borderOpacity})`;
36
39
  const backgroundColor = `hsl(${color} / ${backgroundOpacity})`;
37
40
 
38
41
  useEffect(() => {
39
- if (!slug) return;
42
+ if (!normalizedSlug) return;
40
43
  if (!ref.current) return;
41
44
 
42
45
  const onMouseEnter = () => {
43
- document.querySelectorAll(`[${DATA_ATTR}="${slug}"]`).forEach((el) => {
44
- if (el instanceof HTMLElement) {
45
- el.dataset.active = "true";
46
- }
47
- });
46
+ document
47
+ .querySelectorAll(`[${DATA_ATTR}="${normalizedSlug}"]`)
48
+ .forEach((el) => {
49
+ if (el instanceof HTMLElement) {
50
+ el.dataset.active = "true";
51
+ }
52
+ });
48
53
  };
49
54
  const onMouseLeave = () => {
50
- document.querySelectorAll(`[${DATA_ATTR}="${slug}"]`).forEach((el) => {
51
- if (el instanceof HTMLElement) {
52
- el.dataset.active = "false";
53
- }
54
- });
55
+ document
56
+ .querySelectorAll(`[${DATA_ATTR}="${normalizedSlug}"]`)
57
+ .forEach((el) => {
58
+ if (el instanceof HTMLElement) {
59
+ el.dataset.active = "false";
60
+ }
61
+ });
55
62
  };
56
63
 
57
64
  ref.current.addEventListener("mouseenter", onMouseEnter);
@@ -61,12 +68,12 @@ export const ColorizedParam = ({
61
68
  ref.current?.removeEventListener("mouseenter", onMouseEnter);
62
69
  ref.current?.removeEventListener("mouseleave", onMouseLeave);
63
70
  };
64
- }, [slug]);
71
+ }, [normalizedSlug]);
65
72
 
66
73
  return (
67
74
  <span
68
75
  className={cn("inline-flex relative rounded group", className)}
69
- {...{ [DATA_ATTR]: slug }}
76
+ {...{ [DATA_ATTR]: normalizedSlug }}
70
77
  ref={ref}
71
78
  onClick={onClick}
72
79
  >
@@ -51,11 +51,10 @@ export const ResponsesSidecarBox = ({
51
51
  Empty Response
52
52
  </span>
53
53
  )}
54
- <hr className="border-border my-1" />
55
- <div className="text-xs text-muted-foreground">
56
- {responses[tabIndex].description}
57
- </div>
58
54
  </SidecarBox.Body>
55
+ <SidecarBox.Footer className="flex justify-end text-xs">
56
+ {responses[tabIndex].description}
57
+ </SidecarBox.Footer>
59
58
  </SidecarBox.Root>
60
59
  );
61
60
  };
@@ -1,5 +1,5 @@
1
1
  import { HTTPSnippet } from "@zudoku/httpsnippet";
2
- import { Fragment, useMemo } from "react";
2
+ import { Fragment, useMemo, useTransition } from "react";
3
3
  import { useSearchParams } from "react-router-dom";
4
4
  import { SyntaxHighlight } from "../../components/SyntaxHighlight.js";
5
5
  import type { SchemaObject } from "../../oas/parser/index.js";
@@ -67,6 +67,8 @@ export const Sidecar = ({
67
67
  MethodTextColorMap[operation.method as keyof typeof MethodTextColorMap];
68
68
 
69
69
  const [searchParams, setSearchParams] = useSearchParams();
70
+ const [, startTransition] = useTransition();
71
+
70
72
  const selectedLang = searchParams.get("lang") ?? "shell";
71
73
 
72
74
  const requestBodyContent = operation.requestBody?.content;
@@ -115,7 +117,7 @@ export const Sidecar = ({
115
117
  return (
116
118
  <aside className="flex flex-col overflow-hidden sticky top-[--scroll-padding] gap-4">
117
119
  <SidecarBox.Root>
118
- <SidecarBox.Head className="flex justify-between items-center flex-nowrap p-2 gap-2 text-xs">
120
+ <SidecarBox.Head className="flex justify-between items-center flex-nowrap py-3 gap-2 text-xs">
119
121
  <span className="font-mono break-words">
120
122
  <span className={cn("font-semibold", methodTextColor)}>
121
123
  {operation.method.toLocaleUpperCase()}
@@ -123,27 +125,7 @@ export const Sidecar = ({
123
125
  &nbsp;
124
126
  {path}
125
127
  </span>
126
- <div className="flex gap-2 items-center">
127
- <SimpleSelect
128
- className="self-start"
129
- value={selectedLang}
130
- onChange={(e) => setSearchParams({ lang: e.target.value })}
131
- options={[
132
- { value: "shell", label: "cURL" },
133
- { value: "js", label: "Javascript" },
134
- { value: "python", label: "Python" },
135
- { value: "java", label: "Java" },
136
- { value: "go", label: "Go" },
137
- { value: "csharp", label: "C#" },
138
- { value: "kotlin", label: "Kotlin" },
139
- { value: "objc", label: "Objective C" },
140
- { value: "php", label: "PHP" },
141
- { value: "ruby", label: "Ruby" },
142
- { value: "swift", label: "Swift" },
143
- ]}
144
- />
145
- <PlaygroundDialogWrapper operation={operation} />
146
- </div>
128
+ <PlaygroundDialogWrapper operation={operation} />
147
129
  </SidecarBox.Head>
148
130
  <SidecarBox.Body>
149
131
  <SyntaxHighlight
@@ -153,6 +135,31 @@ export const Sidecar = ({
153
135
  code={code}
154
136
  />
155
137
  </SidecarBox.Body>
138
+ <SidecarBox.Footer className="flex items-center text-xs gap-2 justify-end py-1">
139
+ <span>Show example in</span>
140
+ <SimpleSelect
141
+ className="self-start max-w-[150px]"
142
+ value={selectedLang}
143
+ onChange={(e) => {
144
+ startTransition(() => {
145
+ setSearchParams({ lang: e.target.value });
146
+ });
147
+ }}
148
+ options={[
149
+ { value: "shell", label: "cURL" },
150
+ { value: "js", label: "Javascript" },
151
+ { value: "python", label: "Python" },
152
+ { value: "java", label: "Java" },
153
+ { value: "go", label: "Go" },
154
+ { value: "csharp", label: "C#" },
155
+ { value: "kotlin", label: "Kotlin" },
156
+ { value: "objc", label: "Objective C" },
157
+ { value: "php", label: "PHP" },
158
+ { value: "ruby", label: "Ruby" },
159
+ { value: "swift", label: "Swift" },
160
+ ]}
161
+ />
162
+ </SidecarBox.Footer>
156
163
  </SidecarBox.Root>
157
164
  {requestBodyContent && (
158
165
  <RequestBodySidecarBox content={requestBodyContent} />
@@ -19,7 +19,7 @@ export const Root = ({ children, className }: BaseComponentProps) => (
19
19
  export const Head = ({ children, className }: BaseComponentProps) => (
20
20
  <div
21
21
  className={cn(
22
- "border-b border-b-border dark:border-b-zinc-600 bg-zinc-100 dark:bg-zinc-700 p-2",
22
+ "border-b dark:border-zinc-600 bg-zinc-100 dark:bg-zinc-700 p-2",
23
23
  className,
24
24
  )}
25
25
  >
@@ -34,3 +34,14 @@ export const Body = ({ children, className }: BaseComponentProps) => (
34
34
  {children}
35
35
  </div>
36
36
  );
37
+
38
+ export const Footer = ({ children, className }: BaseComponentProps) => (
39
+ <div
40
+ className={cn(
41
+ "border-t dark:border-zinc-600 bg-zinc-100 dark:bg-zinc-700 p-2",
42
+ className,
43
+ )}
44
+ >
45
+ {children}
46
+ </div>
47
+ );
@@ -1,31 +1,17 @@
1
- import { forwardRef, InputHTMLAttributes } from "react";
2
- import { Control, useFieldArray, UseFormRegister } from "react-hook-form";
1
+ import { EraserIcon } from "lucide-react";
2
+ import {
3
+ Control,
4
+ Controller,
5
+ useFieldArray,
6
+ useFormContext,
7
+ UseFormRegister,
8
+ } from "react-hook-form";
9
+ import { Button } from "../../../ui/Button.js";
10
+ import { Input } from "../../../ui/Input.js";
3
11
  import { cn } from "../../../util/cn.js";
4
- import { DATA_ATTR, usePastellizedColor } from "../ColorizedParam.js";
5
- import { InlineInput } from "./InlineInput.js";
12
+ import { ColorizedParam } from "../ColorizedParam.js";
6
13
  import type { PlaygroundForm } from "./Playground.js";
7
14
 
8
- type ParameterValueProps = {
9
- part: string;
10
- } & InputHTMLAttributes<HTMLInputElement>;
11
-
12
- const ParameterValue = forwardRef<HTMLInputElement, ParameterValueProps>(
13
- function ParameterValue({ part, className, ...props }, ref) {
14
- const color = usePastellizedColor(part);
15
- return (
16
- <InlineInput
17
- {...props}
18
- ref={ref}
19
- className={cn(className, "opacity-80 data-[active=true]:opacity-100")}
20
- style={{
21
- // color: `hsl(${color})`,
22
- outlineColor: `hsl(${color})`,
23
- }}
24
- />
25
- );
26
- },
27
- );
28
-
29
15
  export const PathParams = ({
30
16
  control,
31
17
  register,
@@ -33,31 +19,77 @@ export const PathParams = ({
33
19
  register: UseFormRegister<PlaygroundForm>;
34
20
  control: Control<PlaygroundForm>;
35
21
  }) => {
22
+ const form = useFormContext<PlaygroundForm>();
36
23
  const { fields } = useFieldArray<PlaygroundForm>({
37
24
  control,
38
25
  name: "pathParams",
39
26
  });
40
27
 
41
- return fields.map((part, i) => (
42
- <div
43
- key={part.id}
44
- className="grid-cols-subgrid col-span-full grid items-center gap-x-2 has-[:focus]:bg-muted hover:bg-muted rounded overflow-hidden group"
45
- >
46
- <InlineInput
47
- {...register(`pathParams.${i}.name`)}
48
- disabled
49
- placeholder="Name"
50
- className="peer"
51
- />
52
- <ParameterValue
53
- {...register(`pathParams.${i}.value`)}
54
- part={part.name}
55
- {...{ [DATA_ATTR]: part.name }}
56
- placeholder="Value"
57
- className="peer"
58
- />
59
-
60
- <div className="col-span-full border-b border-border"></div>
61
- </div>
62
- ));
28
+ return (
29
+ <table className="w-full table-auto [&_td]:border [&_td]:py-1 [&_td]:px-2">
30
+ <tbody>
31
+ {fields.map((part, i) => (
32
+ <tr key={part.id} className="hover:bg-accent/40">
33
+ <td>
34
+ <Controller
35
+ control={control}
36
+ name={`pathParams.${i}.value`}
37
+ render={({ field }) => (
38
+ <ColorizedParam
39
+ slug={part.name}
40
+ name={part.name}
41
+ backgroundOpacity="0"
42
+ borderOpacity={field.value ? "100%" : "0"}
43
+ className={cn(
44
+ "font-mono text-xs m-2",
45
+ !field.value && "opacity-60",
46
+ )}
47
+ />
48
+ )}
49
+ />
50
+ </td>
51
+ <td>
52
+ <div className="flex justify-between items-center">
53
+ <Controller
54
+ control={control}
55
+ name={`pathParams.${i}.value`}
56
+ render={({ field }) => (
57
+ <Input
58
+ {...field}
59
+ placeholder="Enter value"
60
+ className={cn(
61
+ "border-0 shadow-none ring-0 font-mono text-xs",
62
+ )}
63
+ />
64
+ )}
65
+ />
66
+ <Controller
67
+ control={control}
68
+ name={`pathParams.${i}.value`}
69
+ render={({ field }) => (
70
+ <Button
71
+ size="icon"
72
+ type="button"
73
+ variant="ghost"
74
+ aria-label="Clear value"
75
+ className={cn(
76
+ "ms-2",
77
+ field.value.length === 0
78
+ ? "opacity-0 pointer-events-none"
79
+ : "opacity-100",
80
+ )}
81
+ title="Clear value"
82
+ onClick={() => field.onChange("")}
83
+ >
84
+ <EraserIcon size={16} />
85
+ </Button>
86
+ )}
87
+ />
88
+ </div>
89
+ </td>
90
+ </tr>
91
+ ))}
92
+ </tbody>
93
+ </table>
94
+ );
63
95
  };
@@ -152,26 +152,31 @@ export const Playground = ({
152
152
  },
153
153
  });
154
154
 
155
- const path = url.split("/").map((part, i, arr) => (
156
- <Fragment key={part}>
157
- {part.startsWith("{") && part.endsWith("}") ? (
158
- <ColorizedParam
159
- name={part}
160
- backgroundOpacity="0"
161
- slug={part.slice(1, -1)}
162
- >
163
- {
164
- formState.pathParams.find((p) => p.name === part.slice(1, -1))
165
- ?.value
166
- }
167
- </ColorizedParam>
168
- ) : (
169
- part
170
- )}
171
- {i < arr.length - 1 && "/"}
172
- <wbr />
173
- </Fragment>
174
- ));
155
+ const path = url.split("/").map((part, i, arr) => {
156
+ const isPathParam = part.startsWith("{") && part.endsWith("}");
157
+ const value = formState.pathParams.find(
158
+ (p) => p.name === part.slice(1, -1),
159
+ )?.value;
160
+
161
+ const pathParamValue = value ? (
162
+ <ColorizedParam backgroundOpacity="0%" name={part} slug={part}>
163
+ {value}
164
+ </ColorizedParam>
165
+ ) : (
166
+ <span className="underline decoration-wavy decoration-red-500">
167
+ {part}
168
+ </span>
169
+ );
170
+
171
+ return (
172
+ // eslint-disable-next-line react/no-array-index-key
173
+ <Fragment key={part + i}>
174
+ {isPathParam ? pathParamValue : part}
175
+ {i < arr.length - 1 && "/"}
176
+ <wbr />
177
+ </Fragment>
178
+ );
179
+ });
175
180
 
176
181
  const lang = mimeTypeToLanguage(
177
182
  queryMutation.data?.headers.get("Content-Type") ?? "",
@@ -251,20 +256,18 @@ export const Playground = ({
251
256
  <Headers control={control} register={register} />
252
257
  </TabsContent>
253
258
  <TabsContent value="parameters">
254
- <div className="grid grid-cols-[min-content_1fr_1fr_auto]">
255
- {pathParams.length > 0 && (
256
- <div className="font-semibold my-3 col-span-3">
257
- Path Parameters
258
- </div>
259
- )}
260
- <PathParams control={control} register={register} />
261
- {queryParams.length > 0 && (
262
- <span className="font-semibold my-3 col-span-3">
263
- Query Parameters
264
- </span>
265
- )}
266
- <QueryParams control={control} />
267
- </div>
259
+ {pathParams.length > 0 && (
260
+ <div className="flex flex-col gap-4 my-4">
261
+ <span className="font-semibold">Path Parameters</span>
262
+ <PathParams control={control} register={register} />
263
+ </div>
264
+ )}
265
+ {queryParams.length > 0 && (
266
+ <div className="flex flex-col gap-4 my-4">
267
+ <span className="font-semibold">Query Parameters</span>
268
+ <QueryParams control={control} />
269
+ </div>
270
+ )}
268
271
  </TabsContent>
269
272
  <TabsContent value="body">
270
273
  <textarea
@@ -1,10 +1,12 @@
1
- import { XIcon } from "lucide-react";
1
+ import { EraserIcon } from "lucide-react";
2
2
  import {
3
3
  Control,
4
4
  Controller,
5
5
  useFieldArray,
6
6
  useFormContext,
7
7
  } from "react-hook-form";
8
+ import { Button } from "../../../ui/Button.js";
9
+ import { Input } from "../../../ui/Input.js";
8
10
  import { cn } from "../../../util/cn.js";
9
11
  import { InlineInput } from "./InlineInput.js";
10
12
  import type { PlaygroundForm } from "./Playground.js";
@@ -21,74 +23,96 @@ export const QueryParams = ({
21
23
  const form = useFormContext<PlaygroundForm>();
22
24
 
23
25
  const requiredFields = form
24
- .getValues(`queryParams`)
26
+ .getValues("queryParams")
25
27
  .map((param) => param.isRequired);
26
28
 
27
- return fields.map((field, i) => (
28
- <div
29
- key={field.id}
30
- className="px-2 grid-cols-subgrid col-span-full grid items-center gap-x-2 has-[:focus]:bg-muted hover:bg-accent rounded overflow-hidden group"
31
- >
32
- <Controller
33
- control={control}
34
- name={`queryParams.${i}.active`}
35
- render={({ field }) => (
36
- <input
37
- type="checkbox"
38
- id={`queryParams.${i}.active`}
39
- checked={field.value}
40
- onChange={field.onChange}
41
- />
42
- )}
43
- />
44
-
45
- <Controller
46
- control={control}
47
- render={({ field }) => {
48
- return (
49
- <InlineInput asChild>
50
- <label
51
- className="flex items-center"
52
- htmlFor={`queryParams.${i}.active`}
53
- title={requiredFields[i] ? "Required field" : undefined}
54
- >
55
- {field.value}
56
- {requiredFields[i] && <sup className="text-destructive">*</sup>}
57
- </label>
58
- </InlineInput>
59
- );
60
- }}
61
- name={`queryParams.${i}.name`}
62
- />
63
- <Controller
64
- control={control}
65
- render={({ field }) => {
66
- return (
67
- <InlineInput {...field} placeholder="Value" className="peer" />
68
- );
69
- }}
70
- name={`queryParams.${i}.value`}
71
- />
72
- <Controller
73
- control={control}
74
- render={({ field }) => {
75
- return (
76
- <button
77
- type="button"
78
- className={cn(
79
- "hover:bg-black/5 p-1 rounded mr-2 text-muted-foreground invisible group-hover:visible peer-focus:visible",
80
- field.value.length === 0 && "opacity-0 pointer-events-none",
81
- )}
82
- onClick={() => field.onChange("")}
83
- >
84
- <XIcon size={16} />
85
- </button>
86
- );
87
- }}
88
- name={`queryParams.${i}.value`}
89
- />
90
-
91
- <div className="-mx-2 col-span-full border-b border-border"></div>
29
+ return (
30
+ <div className="">
31
+ <table className="w-full [&_td]:border [&_td]:p-1.5 [&_td]:px-2">
32
+ <tbody>
33
+ {fields.map((field, i) => (
34
+ <tr key={field.id} className="hover:bg-accent/40">
35
+ <td className="text-center">
36
+ <Controller
37
+ control={control}
38
+ name={`queryParams.${i}.active`}
39
+ render={({ field }) => (
40
+ <input
41
+ type="checkbox"
42
+ id={`queryParams.${i}.active`}
43
+ checked={field.value}
44
+ onChange={field.onChange}
45
+ />
46
+ )}
47
+ />
48
+ </td>
49
+ <td>
50
+ <Controller
51
+ control={control}
52
+ render={({ field }) => (
53
+ <InlineInput asChild>
54
+ <label
55
+ className="flex items-center cursor-pointer"
56
+ htmlFor={`queryParams.${i}.active`}
57
+ title={requiredFields[i] ? "Required field" : undefined}
58
+ >
59
+ {field.value}
60
+ {requiredFields[i] && (
61
+ <sup className="text-destructive">*</sup>
62
+ )}
63
+ </label>
64
+ </InlineInput>
65
+ )}
66
+ name={`queryParams.${i}.name`}
67
+ />
68
+ </td>
69
+ <td>
70
+ <div className="flex justify-between items-center">
71
+ <Controller
72
+ control={control}
73
+ render={({ field }) => (
74
+ <Input
75
+ {...field}
76
+ onChange={(e) => {
77
+ field.onChange(e.target.value);
78
+ if (e.target.value.length > 0) {
79
+ form.setValue(`queryParams.${i}.active`, true);
80
+ }
81
+ }}
82
+ placeholder="Enter value"
83
+ className="w-full border-0 shadow-none text-xs font-mono"
84
+ />
85
+ )}
86
+ name={`queryParams.${i}.value`}
87
+ />
88
+ <Controller
89
+ control={control}
90
+ render={({ field }) => (
91
+ <Button
92
+ size="icon"
93
+ type="button"
94
+ variant="ghost"
95
+ aria-label="Clear value"
96
+ className={cn(
97
+ "ms-2",
98
+ field.value.length === 0
99
+ ? "opacity-0 pointer-events-none"
100
+ : "opacity-100",
101
+ )}
102
+ title="Clear value"
103
+ onClick={() => field.onChange("")}
104
+ >
105
+ <EraserIcon size={16} />
106
+ </Button>
107
+ )}
108
+ name={`queryParams.${i}.value`}
109
+ />
110
+ </div>
111
+ </td>
112
+ </tr>
113
+ ))}
114
+ </tbody>
115
+ </table>
92
116
  </div>
93
- ));
117
+ );
94
118
  };
@@ -1 +0,0 @@
1
- {"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../src/lib/components/Input.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAKnC,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAC5B,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE;IACrC,OAAO,CACL,gBACE,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,EAAE,CACX,uUAAuU,EACvU,SAAS,CACV,EACD,GAAG,EAAE,GAAG,KACJ,KAAK,GACT,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AACF,KAAK,CAAC,WAAW,GAAG,OAAO,CAAC;AAE5B,OAAO,EAAE,KAAK,EAAE,CAAC"}