@lukoweb/apitogo 0.1.1 → 0.1.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.
- package/dist/cli/cli.js +168 -57
- package/dist/declarations/lib/ui/Command.d.ts +1 -1
- package/dist/declarations/lib/util/MdxComponents.d.ts +1 -1
- package/package.json +2 -1
- package/src/app/main.tsx +150 -150
- package/src/config/loader.ts +245 -245
- package/src/index.ts +33 -33
- package/src/lib/authentication/components/CallbackHandler.tsx +45 -45
- package/src/lib/authentication/components/SignIn.tsx +46 -46
- package/src/lib/authentication/components/SignUp.tsx +48 -48
- package/src/lib/authentication/providers/clerk.tsx +224 -224
- package/src/lib/authentication/ui/AuthCard.tsx +7 -7
- package/src/lib/authentication/ui/EmailLinkCallbackUi.tsx +129 -125
- package/src/lib/authentication/ui/EmailLinkSentUi.tsx +105 -101
- package/src/lib/authentication/ui/EmailLinkSignInUi.tsx +100 -96
- package/src/lib/authentication/ui/EmailVerificationUi.tsx +128 -124
- package/src/lib/authentication/ui/ZudokuAuthUi.tsx +620 -616
- package/src/lib/components/AiAssistantMenuItems.tsx +102 -102
- package/src/lib/components/Autocomplete.tsx +123 -123
- package/src/lib/components/DeveloperHint.tsx +39 -35
- package/src/lib/components/Header.tsx +260 -260
- package/src/lib/components/Layout.tsx +53 -53
- package/src/lib/components/Main.tsx +51 -51
- package/src/lib/components/Mermaid.tsx +74 -70
- package/src/lib/components/MobileTopNavigation.tsx +276 -276
- package/src/lib/components/MultiSelect.tsx +86 -82
- package/src/lib/components/TopNavigation.tsx +103 -103
- package/src/lib/components/index.ts +26 -26
- package/src/lib/components/navigation/NavigationCategory.tsx +157 -157
- package/src/lib/components/navigation/NavigationFilterInput.tsx +35 -35
- package/src/lib/components/navigation/NavigationItem.tsx +181 -177
- package/src/lib/core/RouteGuard.tsx +193 -193
- package/src/lib/errors/ErrorMessage.tsx +50 -46
- package/src/lib/plugins/api-catalog/Catalog.tsx +80 -80
- package/src/lib/plugins/api-keys/CreateApiKey.tsx +128 -124
- package/src/lib/plugins/api-keys/CreateApiKeyDialog.tsx +49 -49
- package/src/lib/plugins/api-keys/SettingsApiKeys.tsx +72 -72
- package/src/lib/plugins/api-keys/settings/ApiKeyItem.tsx +342 -342
- package/src/lib/plugins/api-keys/settings/RevealApiKey.tsx +127 -127
- package/src/lib/plugins/markdown/MdxPage.tsx +285 -285
- package/src/lib/plugins/openapi/ApiHeader.tsx +96 -96
- package/src/lib/plugins/openapi/CollapsibleCode.tsx +88 -88
- package/src/lib/plugins/openapi/DownloadSchemaButton.tsx +94 -94
- package/src/lib/plugins/openapi/GeneratedExampleSidecarBox.tsx +52 -52
- package/src/lib/plugins/openapi/OperationListItem.tsx +183 -183
- package/src/lib/plugins/openapi/RequestBodySidecarBox.tsx +63 -63
- package/src/lib/plugins/openapi/ResponsesSidecarBox.tsx +120 -117
- package/src/lib/plugins/openapi/SchemaInfo.tsx +344 -344
- package/src/lib/plugins/openapi/SchemaList.tsx +113 -113
- package/src/lib/plugins/openapi/Sidecar.tsx +312 -309
- package/src/lib/plugins/openapi/SidecarExamples.tsx +177 -174
- package/src/lib/plugins/openapi/components/EnumValues.tsx +58 -58
- package/src/lib/plugins/openapi/components/ResponseContent.tsx +117 -114
- package/src/lib/plugins/openapi/playground/BodyPanel.tsx +274 -271
- package/src/lib/plugins/openapi/playground/CollapsibleHeader.tsx +51 -51
- package/src/lib/plugins/openapi/playground/ExamplesDropdown.tsx +60 -60
- package/src/lib/plugins/openapi/playground/Headers.tsx +188 -181
- package/src/lib/plugins/openapi/playground/IdentityDialog.tsx +75 -75
- package/src/lib/plugins/openapi/playground/IdentitySelector.tsx +38 -38
- package/src/lib/plugins/openapi/playground/ParamsGrid.tsx +45 -45
- package/src/lib/plugins/openapi/playground/Playground.tsx +602 -599
- package/src/lib/plugins/openapi/playground/PlaygroundDialog.tsx +56 -56
- package/src/lib/plugins/openapi/playground/QueryParams.tsx +151 -148
- package/src/lib/plugins/openapi/playground/RequestLoginDialog.tsx +70 -70
- package/src/lib/plugins/openapi/playground/request-panel/MultipartField.tsx +91 -91
- package/src/lib/plugins/openapi/playground/result-panel/AudioPlayer.tsx +50 -50
- package/src/lib/plugins/openapi/playground/result-panel/ResponseTab.tsx +355 -355
- package/src/lib/plugins/openapi/playground/result-panel/ResultPanel.tsx +106 -102
- package/src/lib/plugins/openapi/schema/SchemaPropertyItem.tsx +189 -184
- package/src/lib/plugins/openapi/schema/SchemaView.tsx +299 -299
- package/src/lib/plugins/search-pagefind/IndexingDialog.tsx +162 -162
- package/src/lib/plugins/search-pagefind/PagefindSearch.tsx +202 -202
- package/src/lib/plugins/search-pagefind/ResultList.tsx +122 -118
- package/src/lib/ui/ActionButton.tsx +21 -21
- package/src/lib/ui/Command.tsx +191 -191
- package/src/lib/util/MdxComponents.tsx +150 -150
- package/src/vite/config.ts +234 -231
- package/src/vite/dev-server.ts +291 -291
- package/src/vite/plugin-api-keys.ts +50 -50
- package/src/vite/plugin-api.ts +320 -318
- package/src/vite/plugin-auth.ts +38 -38
- package/src/vite/plugin-component.ts +45 -39
- package/src/vite/plugin-config.ts +75 -75
- package/src/vite/plugin-custom-pages.ts +36 -36
- package/src/vite/plugin-docs.ts +202 -202
- package/src/vite/plugin-markdown-export.ts +214 -214
- package/src/vite/plugin-mdx.ts +149 -149
- package/src/vite/plugin-navigation.ts +106 -106
- package/src/vite/plugin-search.ts +47 -47
- package/src/vite/plugin.ts +42 -42
- package/src/vite/prerender/prerender.ts +233 -233
|
@@ -1,271 +1,274 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
import {
|
|
22
|
-
import
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
import
|
|
31
|
-
import
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
)}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
1
|
+
import { Button } from "@lukoweb/apitogo/components";
|
|
2
|
+
import {
|
|
3
|
+
Collapsible,
|
|
4
|
+
CollapsibleContent,
|
|
5
|
+
} from "@lukoweb/apitogo/ui/Collapsible.js";
|
|
6
|
+
import {
|
|
7
|
+
DropdownMenu,
|
|
8
|
+
DropdownMenuContent,
|
|
9
|
+
DropdownMenuItem,
|
|
10
|
+
DropdownMenuTrigger,
|
|
11
|
+
} from "@lukoweb/apitogo/ui/DropdownMenu.js";
|
|
12
|
+
import { Textarea } from "@lukoweb/apitogo/ui/Textarea.js";
|
|
13
|
+
import {
|
|
14
|
+
ChevronDownIcon,
|
|
15
|
+
FileInput,
|
|
16
|
+
Grid2x2PlusIcon,
|
|
17
|
+
PaperclipIcon,
|
|
18
|
+
ScanTextIcon,
|
|
19
|
+
XIcon,
|
|
20
|
+
} from "lucide-react";
|
|
21
|
+
import { useRef, useState } from "react";
|
|
22
|
+
import { useFormContext } from "react-hook-form";
|
|
23
|
+
import { cn } from "../../../util/cn.js";
|
|
24
|
+
import { humanFileSize } from "../../../util/humanFileSize.js";
|
|
25
|
+
import type { MediaTypeObject } from "../graphql/graphql.js";
|
|
26
|
+
import {
|
|
27
|
+
CollapsibleHeader,
|
|
28
|
+
CollapsibleHeaderTrigger,
|
|
29
|
+
} from "./CollapsibleHeader.js";
|
|
30
|
+
import ExamplesDropdown from "./ExamplesDropdown.js";
|
|
31
|
+
import ParamsGrid from "./ParamsGrid.js";
|
|
32
|
+
import type { PlaygroundForm } from "./Playground.js";
|
|
33
|
+
import { MultipartField } from "./request-panel/MultipartField.js";
|
|
34
|
+
import { useKeyValueFieldManager } from "./request-panel/useKeyValueFieldManager.js";
|
|
35
|
+
|
|
36
|
+
export const BodyPanel = ({ content }: { content?: MediaTypeObject[] }) => {
|
|
37
|
+
const { register, setValue, watch, control } =
|
|
38
|
+
useFormContext<PlaygroundForm>();
|
|
39
|
+
const examples = (content ?? []).flatMap((e) => e.examples);
|
|
40
|
+
const [headers, file, bodyMode, body, multipartFormFields] = watch([
|
|
41
|
+
"headers",
|
|
42
|
+
"file",
|
|
43
|
+
"bodyMode",
|
|
44
|
+
"body",
|
|
45
|
+
"multipartFormFields",
|
|
46
|
+
]);
|
|
47
|
+
const fileInputRef = useRef<HTMLInputElement>(null);
|
|
48
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
49
|
+
|
|
50
|
+
const handleFileSelect = (selectedFile: File | null) => {
|
|
51
|
+
setValue("file", selectedFile);
|
|
52
|
+
if (!selectedFile) return;
|
|
53
|
+
setValue(
|
|
54
|
+
"headers",
|
|
55
|
+
headers.filter(
|
|
56
|
+
(h) => h.name.toLowerCase() !== "content-type" || !h.active,
|
|
57
|
+
),
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const handleFileInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
62
|
+
const selectedFile = e.target.files?.[0] ?? null;
|
|
63
|
+
handleFileSelect(selectedFile);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const handleDragOver = (e: React.DragEvent<HTMLElement>) => {
|
|
67
|
+
e.preventDefault();
|
|
68
|
+
e.stopPropagation();
|
|
69
|
+
setIsDragging(true);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const handleDragLeave = (e: React.DragEvent<HTMLElement>) => {
|
|
73
|
+
e.preventDefault();
|
|
74
|
+
e.stopPropagation();
|
|
75
|
+
setIsDragging(false);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const handleDrop = (e: React.DragEvent<HTMLElement>) => {
|
|
79
|
+
e.preventDefault();
|
|
80
|
+
e.stopPropagation();
|
|
81
|
+
setIsDragging(false);
|
|
82
|
+
|
|
83
|
+
const droppedFile = e.dataTransfer.files?.[0] ?? null;
|
|
84
|
+
handleFileSelect(droppedFile);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const manager = useKeyValueFieldManager<
|
|
88
|
+
PlaygroundForm,
|
|
89
|
+
"multipartFormFields"
|
|
90
|
+
>({
|
|
91
|
+
control,
|
|
92
|
+
name: "multipartFormFields",
|
|
93
|
+
defaultValue: { name: "", value: "", active: false },
|
|
94
|
+
isEmpty: (item) => {
|
|
95
|
+
if (item.value instanceof File) return false;
|
|
96
|
+
return !item.name && !item.value;
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<Collapsible defaultOpen>
|
|
102
|
+
<CollapsibleHeaderTrigger className="items-center">
|
|
103
|
+
<FileInput size={16} />
|
|
104
|
+
<CollapsibleHeader className="flex items-center justify-between">
|
|
105
|
+
Body
|
|
106
|
+
<div className="flex items-center">
|
|
107
|
+
<DropdownMenu>
|
|
108
|
+
<DropdownMenuTrigger asChild>
|
|
109
|
+
<Button
|
|
110
|
+
variant="ghost"
|
|
111
|
+
size="sm"
|
|
112
|
+
className="hover:bg-accent hover:brightness-95 gap-2"
|
|
113
|
+
>
|
|
114
|
+
{bodyMode === "text" ? (
|
|
115
|
+
<>
|
|
116
|
+
<ScanTextIcon size={14} />
|
|
117
|
+
Text
|
|
118
|
+
</>
|
|
119
|
+
) : bodyMode === "file" ? (
|
|
120
|
+
<>
|
|
121
|
+
<PaperclipIcon size={14} />
|
|
122
|
+
File
|
|
123
|
+
</>
|
|
124
|
+
) : (
|
|
125
|
+
<>
|
|
126
|
+
<Grid2x2PlusIcon size={14} />
|
|
127
|
+
Multipart
|
|
128
|
+
</>
|
|
129
|
+
)}
|
|
130
|
+
<ChevronDownIcon size={14} />
|
|
131
|
+
</Button>
|
|
132
|
+
</DropdownMenuTrigger>
|
|
133
|
+
<DropdownMenuContent className="min-w-40">
|
|
134
|
+
<DropdownMenuItem
|
|
135
|
+
onSelect={() => setValue("bodyMode", "text")}
|
|
136
|
+
className="gap-2"
|
|
137
|
+
>
|
|
138
|
+
<ScanTextIcon size={14} />
|
|
139
|
+
<span className="flex-1">Text</span>
|
|
140
|
+
<span>
|
|
141
|
+
{body.length > 0 && (
|
|
142
|
+
<div className="w-1.5 h-1.5 bg-primary rounded-full" />
|
|
143
|
+
)}
|
|
144
|
+
</span>
|
|
145
|
+
</DropdownMenuItem>
|
|
146
|
+
<DropdownMenuItem
|
|
147
|
+
onSelect={() => setValue("bodyMode", "file")}
|
|
148
|
+
className="gap-2"
|
|
149
|
+
>
|
|
150
|
+
<PaperclipIcon size={14} />
|
|
151
|
+
<span className="flex-1">File</span>
|
|
152
|
+
<span>
|
|
153
|
+
{file && (
|
|
154
|
+
<div className="w-1.5 h-1.5 bg-primary rounded-full" />
|
|
155
|
+
)}
|
|
156
|
+
</span>
|
|
157
|
+
</DropdownMenuItem>
|
|
158
|
+
<DropdownMenuItem
|
|
159
|
+
onSelect={() => setValue("bodyMode", "multipart")}
|
|
160
|
+
className="gap-2"
|
|
161
|
+
>
|
|
162
|
+
<Grid2x2PlusIcon size={14} strokeWidth={1.5} />
|
|
163
|
+
<span className="flex-1">Multipart</span>
|
|
164
|
+
<span>
|
|
165
|
+
{multipartFormFields?.some((field) => field.active) && (
|
|
166
|
+
<div className="w-1.5 h-1.5 bg-primary rounded-full" />
|
|
167
|
+
)}
|
|
168
|
+
</span>
|
|
169
|
+
</DropdownMenuItem>
|
|
170
|
+
</DropdownMenuContent>
|
|
171
|
+
</DropdownMenu>
|
|
172
|
+
<input
|
|
173
|
+
ref={fileInputRef}
|
|
174
|
+
type="file"
|
|
175
|
+
className="hidden"
|
|
176
|
+
onChange={handleFileInputChange}
|
|
177
|
+
/>
|
|
178
|
+
<div className="w-px mx-1 h-5 bg-border" />
|
|
179
|
+
{content && examples.length > 0 ? (
|
|
180
|
+
<ExamplesDropdown
|
|
181
|
+
examples={content}
|
|
182
|
+
onSelect={(example, mediaType) => {
|
|
183
|
+
setValue("body", JSON.stringify(example.value, null, 2));
|
|
184
|
+
setValue("headers", [
|
|
185
|
+
...headers.filter((h) => h.name !== "Content-Type"),
|
|
186
|
+
{
|
|
187
|
+
name: "Content-Type",
|
|
188
|
+
value: mediaType,
|
|
189
|
+
active: true,
|
|
190
|
+
},
|
|
191
|
+
]);
|
|
192
|
+
}}
|
|
193
|
+
/>
|
|
194
|
+
) : (
|
|
195
|
+
<div />
|
|
196
|
+
)}
|
|
197
|
+
</div>
|
|
198
|
+
</CollapsibleHeader>
|
|
199
|
+
</CollapsibleHeaderTrigger>
|
|
200
|
+
<CollapsibleContent className="CollapsibleContent flex flex-col gap-2">
|
|
201
|
+
{bodyMode === "text" && (
|
|
202
|
+
<Textarea
|
|
203
|
+
{...register("body")}
|
|
204
|
+
className={cn(
|
|
205
|
+
"w-full px-4 py-2.5 h-64 font-mono md:text-xs border-none rounded-none focus-visible:ring-0 transition-colors",
|
|
206
|
+
)}
|
|
207
|
+
placeholder="Body content"
|
|
208
|
+
/>
|
|
209
|
+
)}
|
|
210
|
+
{bodyMode === "file" && (
|
|
211
|
+
<div
|
|
212
|
+
role="region"
|
|
213
|
+
aria-label="File upload drop zone"
|
|
214
|
+
className={cn(
|
|
215
|
+
"flex flex-col items-center justify-center gap-4 min-h-[300px]",
|
|
216
|
+
)}
|
|
217
|
+
onDragOver={handleDragOver}
|
|
218
|
+
onDragLeave={handleDragLeave}
|
|
219
|
+
onDrop={handleDrop}
|
|
220
|
+
>
|
|
221
|
+
<button
|
|
222
|
+
type="button"
|
|
223
|
+
onClick={() => fileInputRef.current?.click()}
|
|
224
|
+
className={cn(
|
|
225
|
+
"flex items-center justify-center gap-2 rounded-full size-20 p-0 border border-dashed border-muted-foreground/50 hover:bg-accent/75 transition-colors",
|
|
226
|
+
(file || isDragging) && "border-solid",
|
|
227
|
+
isDragging && "bg-accent border-primary",
|
|
228
|
+
)}
|
|
229
|
+
>
|
|
230
|
+
<PaperclipIcon
|
|
231
|
+
className={cn(
|
|
232
|
+
"text-muted-foreground",
|
|
233
|
+
isDragging && "text-primary",
|
|
234
|
+
)}
|
|
235
|
+
size={30}
|
|
236
|
+
/>
|
|
237
|
+
</button>
|
|
238
|
+
{file ? (
|
|
239
|
+
<div className="flex items-center justify-between gap-2 px-2 py-1.5 rounded-md border">
|
|
240
|
+
<span className="text-sm truncate" title={file.name}>
|
|
241
|
+
{file.name}{" "}
|
|
242
|
+
<span className="text-muted-foreground">
|
|
243
|
+
({humanFileSize(file.size)})
|
|
244
|
+
</span>
|
|
245
|
+
</span>
|
|
246
|
+
<Button
|
|
247
|
+
type="button"
|
|
248
|
+
variant="ghost"
|
|
249
|
+
size="icon-xs"
|
|
250
|
+
onClick={() => handleFileSelect(null)}
|
|
251
|
+
>
|
|
252
|
+
<XIcon size={14} />
|
|
253
|
+
</Button>
|
|
254
|
+
</div>
|
|
255
|
+
) : (
|
|
256
|
+
<span className="text-lg font-semibold text-muted-foreground">
|
|
257
|
+
Select or drop a file
|
|
258
|
+
</span>
|
|
259
|
+
)}
|
|
260
|
+
</div>
|
|
261
|
+
)}
|
|
262
|
+
{bodyMode === "multipart" && (
|
|
263
|
+
<ParamsGrid>
|
|
264
|
+
{manager.fields.map((field, index) => (
|
|
265
|
+
<MultipartField key={field.id} index={index} manager={manager} />
|
|
266
|
+
))}
|
|
267
|
+
</ParamsGrid>
|
|
268
|
+
)}
|
|
269
|
+
</CollapsibleContent>
|
|
270
|
+
</Collapsible>
|
|
271
|
+
);
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
export default BodyPanel;
|