@openpkg-ts/ui 0.4.0 → 0.5.0
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/docskit/index.d.ts +276 -33
- package/dist/docskit/index.js +1510 -1277
- package/package.json +11 -1
- package/src/styles/docskit.css +28 -3
package/dist/docskit/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
// src/docskit/api/api-code-panel.tsx
|
|
3
|
-
import {
|
|
4
|
-
import { Check, Copy, ExternalLink } from "lucide-react";
|
|
5
|
-
import { useEffect as useEffect2, useState as useState3 } from "react";
|
|
3
|
+
import { useState as useState5 } from "react";
|
|
6
4
|
|
|
7
5
|
// src/lib/utils.ts
|
|
8
6
|
import { clsx } from "clsx";
|
|
@@ -11,6 +9,43 @@ function cn(...inputs) {
|
|
|
11
9
|
return twMerge(clsx(inputs));
|
|
12
10
|
}
|
|
13
11
|
|
|
12
|
+
// src/docskit/code.client-highlight.tsx
|
|
13
|
+
import {
|
|
14
|
+
highlight,
|
|
15
|
+
Inline,
|
|
16
|
+
Pre
|
|
17
|
+
} from "codehike/code";
|
|
18
|
+
import { useEffect, useState as useState3 } from "react";
|
|
19
|
+
|
|
20
|
+
// src/hooks/use-local-storage.ts
|
|
21
|
+
import React from "react";
|
|
22
|
+
function useStateOrLocalStorage(key, initialState) {
|
|
23
|
+
const [state, setState] = React.useState(initialState);
|
|
24
|
+
React.useLayoutEffect(() => {
|
|
25
|
+
if (!key)
|
|
26
|
+
return;
|
|
27
|
+
const storedValue = window.localStorage.getItem(key);
|
|
28
|
+
if (storedValue != null) {
|
|
29
|
+
setState(storedValue);
|
|
30
|
+
}
|
|
31
|
+
const onStorageChange = (e) => {
|
|
32
|
+
if (e.key === key) {
|
|
33
|
+
const storedValue2 = window.localStorage.getItem(key);
|
|
34
|
+
setState(storedValue2 || initialState);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
window.addEventListener("storage", onStorageChange);
|
|
38
|
+
return () => window.removeEventListener("storage", onStorageChange);
|
|
39
|
+
}, [key, initialState]);
|
|
40
|
+
const setStorage = !key ? setState : (value) => {
|
|
41
|
+
if (typeof window !== "undefined") {
|
|
42
|
+
window.localStorage.setItem(key, value);
|
|
43
|
+
window.dispatchEvent(new StorageEvent("storage", { key }));
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
return [state, setStorage];
|
|
47
|
+
}
|
|
48
|
+
|
|
14
49
|
// src/docskit/code.config.ts
|
|
15
50
|
var theme = "github-from-css";
|
|
16
51
|
function flagsToOptions(flags = "") {
|
|
@@ -34,43 +69,77 @@ function flagsToOptions(flags = "") {
|
|
|
34
69
|
return options;
|
|
35
70
|
}
|
|
36
71
|
|
|
72
|
+
// src/docskit/code.copy.tsx
|
|
73
|
+
import { Check, Copy } from "lucide-react";
|
|
74
|
+
import { useState } from "react";
|
|
75
|
+
import { jsx } from "react/jsx-runtime";
|
|
76
|
+
|
|
77
|
+
function CopyButton({
|
|
78
|
+
text,
|
|
79
|
+
className,
|
|
80
|
+
variant = "floating"
|
|
81
|
+
}) {
|
|
82
|
+
const [copied, setCopied] = useState(false);
|
|
83
|
+
return /* @__PURE__ */ jsx("button", {
|
|
84
|
+
type: "button",
|
|
85
|
+
className: cn("cursor-pointer transition-opacity duration-200", variant === "floating" && [
|
|
86
|
+
"size-8 flex items-center justify-center",
|
|
87
|
+
"rounded border border-openpkg-code-border bg-openpkg-code-bg",
|
|
88
|
+
"opacity-0 group-hover:opacity-100"
|
|
89
|
+
], variant === "inline" && "rounded", className),
|
|
90
|
+
onClick: () => {
|
|
91
|
+
navigator.clipboard.writeText(text);
|
|
92
|
+
setCopied(true);
|
|
93
|
+
setTimeout(() => setCopied(false), 1200);
|
|
94
|
+
},
|
|
95
|
+
"aria-label": "Copy to clipboard",
|
|
96
|
+
children: copied ? /* @__PURE__ */ jsx(Check, {
|
|
97
|
+
size: 16,
|
|
98
|
+
className: "block"
|
|
99
|
+
}) : /* @__PURE__ */ jsx(Copy, {
|
|
100
|
+
size: 16,
|
|
101
|
+
className: "block"
|
|
102
|
+
})
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
37
106
|
// src/docskit/callout.tsx
|
|
38
107
|
import { InnerLine } from "codehike/code";
|
|
39
108
|
|
|
40
109
|
// src/docskit/notes.client.tsx
|
|
41
|
-
import
|
|
42
|
-
import { jsx } from "react/jsx-runtime";
|
|
110
|
+
import React2 from "react";
|
|
111
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
43
112
|
|
|
44
|
-
var NotesContext =
|
|
113
|
+
var NotesContext = React2.createContext([]);
|
|
45
114
|
function WithClientNotes({ children, notes }) {
|
|
46
|
-
return /* @__PURE__ */
|
|
115
|
+
return /* @__PURE__ */ jsx2(NotesContext.Provider, {
|
|
47
116
|
value: notes,
|
|
48
117
|
children
|
|
49
118
|
});
|
|
50
119
|
}
|
|
51
120
|
function useNotesContext(n) {
|
|
52
|
-
return
|
|
121
|
+
return React2.useContext(NotesContext).find(({ name }) => name === n);
|
|
53
122
|
}
|
|
54
123
|
|
|
55
124
|
// src/docskit/callout.client.tsx
|
|
56
|
-
import { jsx as
|
|
125
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
57
126
|
|
|
58
127
|
function CalloutClient({ name }) {
|
|
59
128
|
const note = useNotesContext(name);
|
|
60
129
|
if (note?.type === "code") {
|
|
61
|
-
return /* @__PURE__ */
|
|
130
|
+
return /* @__PURE__ */ jsx3("div", {
|
|
62
131
|
className: "prose-no-margin [&>div]:!border-none [&>div]:!my-0 [&>div>pre]:!bg-transparent",
|
|
63
132
|
children: note.children
|
|
64
133
|
});
|
|
65
134
|
}
|
|
66
|
-
return /* @__PURE__ */
|
|
135
|
+
return /* @__PURE__ */ jsx3("div", {
|
|
67
136
|
className: "px-2 prose dark:prose-invert",
|
|
68
137
|
children: note ? note.children : name
|
|
69
138
|
});
|
|
70
139
|
}
|
|
71
140
|
|
|
72
141
|
// src/docskit/callout.tsx
|
|
73
|
-
import { jsx as
|
|
142
|
+
import { jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
74
143
|
var callout = {
|
|
75
144
|
name: "callout",
|
|
76
145
|
transform: (annotation) => {
|
|
@@ -101,14 +170,14 @@ var callout = {
|
|
|
101
170
|
},
|
|
102
171
|
className: "w-fit bg-openpkg-code-header rounded px-0 relative my-1 whitespace-break-spaces select-none",
|
|
103
172
|
children: [
|
|
104
|
-
/* @__PURE__ */
|
|
173
|
+
/* @__PURE__ */ jsx4("div", {
|
|
105
174
|
style: {
|
|
106
175
|
left: `${column - indentation - 1}ch`,
|
|
107
176
|
borderColor: "var(--ch-23)"
|
|
108
177
|
},
|
|
109
178
|
className: "absolute border-l border-t w-2 h-2 rotate-45 -translate-y-1/2 -top-[1px] bg-openpkg-code-header"
|
|
110
179
|
}),
|
|
111
|
-
/* @__PURE__ */
|
|
180
|
+
/* @__PURE__ */ jsx4(CalloutClient, {
|
|
112
181
|
name: annotation.query
|
|
113
182
|
})
|
|
114
183
|
]
|
|
@@ -120,17 +189,17 @@ var callout = {
|
|
|
120
189
|
|
|
121
190
|
// src/docskit/code.line.tsx
|
|
122
191
|
import { InnerLine as InnerLine2 } from "codehike/code";
|
|
123
|
-
import { jsx as
|
|
192
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
124
193
|
var line = {
|
|
125
194
|
name: "line",
|
|
126
195
|
Line: ({ annotation, ...props }) => {
|
|
127
|
-
return /* @__PURE__ */
|
|
196
|
+
return /* @__PURE__ */ jsx5("div", {
|
|
128
197
|
style: {
|
|
129
198
|
borderLeftColor: "var(--openpkg-line-border, transparent)",
|
|
130
199
|
backgroundColor: "var(--openpkg-line-bg, transparent)"
|
|
131
200
|
},
|
|
132
201
|
className: "flex border-l-2 border-l-transparent background-color 0.3s ease",
|
|
133
|
-
children: /* @__PURE__ */
|
|
202
|
+
children: /* @__PURE__ */ jsx5(InnerLine2, {
|
|
134
203
|
merge: props,
|
|
135
204
|
className: "px-3 flex-1"
|
|
136
205
|
})
|
|
@@ -144,10 +213,10 @@ import { ChevronDownIcon } from "lucide-react";
|
|
|
144
213
|
|
|
145
214
|
// src/collapsible/collapsible.tsx
|
|
146
215
|
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
|
|
147
|
-
import { jsx as
|
|
216
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
148
217
|
|
|
149
218
|
function Collapsible({ ...props }) {
|
|
150
|
-
return /* @__PURE__ */
|
|
219
|
+
return /* @__PURE__ */ jsx6(CollapsiblePrimitive.Root, {
|
|
151
220
|
"data-slot": "collapsible",
|
|
152
221
|
...props
|
|
153
222
|
});
|
|
@@ -155,7 +224,7 @@ function Collapsible({ ...props }) {
|
|
|
155
224
|
function CollapsibleTrigger2({
|
|
156
225
|
...props
|
|
157
226
|
}) {
|
|
158
|
-
return /* @__PURE__ */
|
|
227
|
+
return /* @__PURE__ */ jsx6(CollapsiblePrimitive.CollapsibleTrigger, {
|
|
159
228
|
"data-slot": "collapsible-trigger",
|
|
160
229
|
...props
|
|
161
230
|
});
|
|
@@ -163,14 +232,14 @@ function CollapsibleTrigger2({
|
|
|
163
232
|
function CollapsibleContent2({
|
|
164
233
|
...props
|
|
165
234
|
}) {
|
|
166
|
-
return /* @__PURE__ */
|
|
235
|
+
return /* @__PURE__ */ jsx6(CollapsiblePrimitive.CollapsibleContent, {
|
|
167
236
|
"data-slot": "collapsible-content",
|
|
168
237
|
...props
|
|
169
238
|
});
|
|
170
239
|
}
|
|
171
240
|
|
|
172
241
|
// src/docskit/collapse.tsx
|
|
173
|
-
import { jsx as
|
|
242
|
+
import { jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
174
243
|
var collapseRoot = {
|
|
175
244
|
name: "collapse",
|
|
176
245
|
transform: (annotation) => {
|
|
@@ -191,22 +260,22 @@ var collapseRoot = {
|
|
|
191
260
|
];
|
|
192
261
|
},
|
|
193
262
|
Block: ({ annotation, children }) => {
|
|
194
|
-
return /* @__PURE__ */
|
|
263
|
+
return /* @__PURE__ */ jsx7(Collapsible, {
|
|
195
264
|
defaultOpen: annotation.query !== "collapsed",
|
|
196
265
|
children
|
|
197
266
|
});
|
|
198
267
|
}
|
|
199
268
|
};
|
|
200
|
-
var icon = /* @__PURE__ */
|
|
269
|
+
var icon = /* @__PURE__ */ jsx7(ChevronDownIcon, {
|
|
201
270
|
className: "inline-block group-data-[state=closed]:-rotate-90 transition select-none opacity-30 group-data-[state=closed]:opacity-80 group-hover:!opacity-100 mb-0.5 ml-1 -mr-1 ",
|
|
202
271
|
size: 15
|
|
203
272
|
});
|
|
204
273
|
var collapseTrigger = {
|
|
205
274
|
name: "CollapseTrigger",
|
|
206
275
|
onlyIfAnnotated: true,
|
|
207
|
-
AnnotatedLine: ({ annotation, ...props }) => /* @__PURE__ */
|
|
276
|
+
AnnotatedLine: ({ annotation, ...props }) => /* @__PURE__ */ jsx7(CollapsibleTrigger2, {
|
|
208
277
|
className: "group contents",
|
|
209
|
-
children: /* @__PURE__ */
|
|
278
|
+
children: /* @__PURE__ */ jsx7(InnerLine3, {
|
|
210
279
|
merge: props,
|
|
211
280
|
data: { icon }
|
|
212
281
|
})
|
|
@@ -216,13 +285,13 @@ var collapseTrigger = {
|
|
|
216
285
|
return /* @__PURE__ */ jsxs2("div", {
|
|
217
286
|
className: "table-row",
|
|
218
287
|
children: [
|
|
219
|
-
/* @__PURE__ */
|
|
288
|
+
/* @__PURE__ */ jsx7("span", {
|
|
220
289
|
className: "w-4 text-center table-cell",
|
|
221
290
|
children: icon2
|
|
222
291
|
}),
|
|
223
|
-
/* @__PURE__ */
|
|
292
|
+
/* @__PURE__ */ jsx7("div", {
|
|
224
293
|
className: "table-cell",
|
|
225
|
-
children: /* @__PURE__ */
|
|
294
|
+
children: /* @__PURE__ */ jsx7(InnerLine3, {
|
|
226
295
|
merge: props
|
|
227
296
|
})
|
|
228
297
|
})
|
|
@@ -238,13 +307,13 @@ var collapse = [collapseRoot, collapseTrigger, collapseContent];
|
|
|
238
307
|
|
|
239
308
|
// src/docskit/diff.tsx
|
|
240
309
|
import { InnerLine as InnerLine4 } from "codehike/code";
|
|
241
|
-
import { jsx as
|
|
310
|
+
import { jsx as jsx8, jsxs as jsxs3, Fragment } from "react/jsx-runtime";
|
|
242
311
|
var diff = {
|
|
243
312
|
name: "diff",
|
|
244
313
|
onlyIfAnnotated: true,
|
|
245
314
|
Block: ({ annotation, children }) => {
|
|
246
315
|
const color = annotation.query === "-" ? "#f85149" : "#3fb950";
|
|
247
|
-
return /* @__PURE__ */
|
|
316
|
+
return /* @__PURE__ */ jsx8("div", {
|
|
248
317
|
style: {
|
|
249
318
|
["--openpkg-line-bg"]: `rgb(from ${color} r g b / 0.13)`,
|
|
250
319
|
["--openpkg-line-border"]: color
|
|
@@ -254,11 +323,11 @@ var diff = {
|
|
|
254
323
|
},
|
|
255
324
|
Line: ({ annotation, ...props }) => /* @__PURE__ */ jsxs3(Fragment, {
|
|
256
325
|
children: [
|
|
257
|
-
/* @__PURE__ */
|
|
326
|
+
/* @__PURE__ */ jsx8("div", {
|
|
258
327
|
className: "min-w-[1ch] box-content opacity-70 pl-2 select-none",
|
|
259
328
|
children: annotation?.query
|
|
260
329
|
}),
|
|
261
|
-
/* @__PURE__ */
|
|
330
|
+
/* @__PURE__ */ jsx8(InnerLine4, {
|
|
262
331
|
merge: props
|
|
263
332
|
})
|
|
264
333
|
]
|
|
@@ -266,7 +335,7 @@ var diff = {
|
|
|
266
335
|
};
|
|
267
336
|
|
|
268
337
|
// src/docskit/expandable.tsx
|
|
269
|
-
import { jsx as
|
|
338
|
+
import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
270
339
|
var expandable = {
|
|
271
340
|
name: "expandable",
|
|
272
341
|
transform: (annotation) => {
|
|
@@ -275,14 +344,14 @@ var expandable = {
|
|
|
275
344
|
Block: ({ children }) => {
|
|
276
345
|
return /* @__PURE__ */ jsxs4(Collapsible, {
|
|
277
346
|
children: [
|
|
278
|
-
/* @__PURE__ */
|
|
347
|
+
/* @__PURE__ */ jsx9(CollapsibleTrigger2, {
|
|
279
348
|
className: "h-24 w-full translate-y-[-75%] absolute bg-gradient-to-b from-openpkg-code-bg/0 via-openpkg-code-bg/80 to-openpkg-code-bg data-[state=open]:invisible",
|
|
280
|
-
children: /* @__PURE__ */
|
|
349
|
+
children: /* @__PURE__ */ jsx9("div", {
|
|
281
350
|
className: "pt-6",
|
|
282
351
|
children: "Expand"
|
|
283
352
|
})
|
|
284
353
|
}),
|
|
285
|
-
/* @__PURE__ */
|
|
354
|
+
/* @__PURE__ */ jsx9(CollapsibleContent2, {
|
|
286
355
|
children
|
|
287
356
|
})
|
|
288
357
|
]
|
|
@@ -294,8 +363,8 @@ var expandable = {
|
|
|
294
363
|
import {
|
|
295
364
|
InnerLine as InnerLine5
|
|
296
365
|
} from "codehike/code";
|
|
297
|
-
import { createContext, useContext, useState } from "react";
|
|
298
|
-
import { jsx as
|
|
366
|
+
import { createContext, useContext, useState as useState2 } from "react";
|
|
367
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
299
368
|
|
|
300
369
|
var HoverContext = createContext({
|
|
301
370
|
hoveredNames: [],
|
|
@@ -303,14 +372,14 @@ var HoverContext = createContext({
|
|
|
303
372
|
removeHoveredName: () => {}
|
|
304
373
|
});
|
|
305
374
|
function HoverProvider({ children }) {
|
|
306
|
-
const [hoveredNames, setHoveredNames] =
|
|
375
|
+
const [hoveredNames, setHoveredNames] = useState2([]);
|
|
307
376
|
const addHoveredName = (name) => {
|
|
308
377
|
setHoveredNames((prev) => [...prev, name]);
|
|
309
378
|
};
|
|
310
379
|
const removeHoveredName = (name) => {
|
|
311
380
|
setHoveredNames((prev) => prev.filter((n) => n !== name));
|
|
312
381
|
};
|
|
313
|
-
return /* @__PURE__ */
|
|
382
|
+
return /* @__PURE__ */ jsx10(HoverContext.Provider, {
|
|
314
383
|
value: { hoveredNames, addHoveredName, removeHoveredName },
|
|
315
384
|
children
|
|
316
385
|
});
|
|
@@ -323,7 +392,7 @@ function Hoverable({
|
|
|
323
392
|
}) {
|
|
324
393
|
const { addHoveredName, removeHoveredName, hoveredNames } = useContext(HoverContext);
|
|
325
394
|
const isHovered = hoveredNames.length > 0 && hoveredNames[hoveredNames.length - 1] === name;
|
|
326
|
-
return /* @__PURE__ */
|
|
395
|
+
return /* @__PURE__ */ jsx10("span", {
|
|
327
396
|
className,
|
|
328
397
|
onMouseEnter: () => addHoveredName(name),
|
|
329
398
|
onMouseLeave: () => removeHoveredName(name),
|
|
@@ -340,7 +409,7 @@ var HoverBlock = ({ annotation, children }) => {
|
|
|
340
409
|
["--openpkg-line-bg"]: `rgb(from ${color} r g b / 0.13)`,
|
|
341
410
|
["--openpkg-line-border"]: color
|
|
342
411
|
} : undefined;
|
|
343
|
-
return /* @__PURE__ */
|
|
412
|
+
return /* @__PURE__ */ jsx10("div", {
|
|
344
413
|
style,
|
|
345
414
|
children
|
|
346
415
|
});
|
|
@@ -353,7 +422,7 @@ var HoverLine = ({ annotation, ...props }) => {
|
|
|
353
422
|
const name = annotation?.query;
|
|
354
423
|
const isHovered = name && hoveredNames[hoveredNames.length - 1] === name;
|
|
355
424
|
const opacity = isHovered ? 1 : prevOpacity ? prevOpacity : anyHovered ? 0.5 : 1;
|
|
356
|
-
return /* @__PURE__ */
|
|
425
|
+
return /* @__PURE__ */ jsx10(InnerLine5, {
|
|
357
426
|
merge: props,
|
|
358
427
|
style: {
|
|
359
428
|
opacity,
|
|
@@ -364,7 +433,7 @@ var HoverLine = ({ annotation, ...props }) => {
|
|
|
364
433
|
var HoverInline = ({ annotation, children }) => {
|
|
365
434
|
const { hoveredNames } = useContext(HoverContext);
|
|
366
435
|
const isHovered = hoveredNames[hoveredNames.length - 1] === annotation.query;
|
|
367
|
-
return /* @__PURE__ */
|
|
436
|
+
return /* @__PURE__ */ jsx10("span", {
|
|
368
437
|
className: "rounded px-0.5 py-0 -mx-0.5",
|
|
369
438
|
style: {
|
|
370
439
|
transition: "background-color 0.3s ease, box-shadow 0.3s ease",
|
|
@@ -376,15 +445,15 @@ var HoverInline = ({ annotation, children }) => {
|
|
|
376
445
|
};
|
|
377
446
|
|
|
378
447
|
// src/docskit/hover.tsx
|
|
379
|
-
import { jsx as
|
|
448
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
380
449
|
function WithHover(props) {
|
|
381
|
-
return /* @__PURE__ */
|
|
450
|
+
return /* @__PURE__ */ jsx11(HoverProvider, {
|
|
382
451
|
children: props.children
|
|
383
452
|
});
|
|
384
453
|
}
|
|
385
454
|
function HoverLink(props) {
|
|
386
455
|
const hover = props.href?.slice("hover:".length) ?? "";
|
|
387
|
-
return /* @__PURE__ */
|
|
456
|
+
return /* @__PURE__ */ jsx11(Hoverable, {
|
|
388
457
|
className: "underline decoration-dotted underline-offset-4 inline cursor-help",
|
|
389
458
|
name: hover,
|
|
390
459
|
children: props.children
|
|
@@ -413,19 +482,19 @@ var hover = {
|
|
|
413
482
|
|
|
414
483
|
// src/docskit/line-numbers.tsx
|
|
415
484
|
import { InnerLine as InnerLine6 } from "codehike/code";
|
|
416
|
-
import { jsx as
|
|
485
|
+
import { jsx as jsx12, jsxs as jsxs5, Fragment as Fragment2 } from "react/jsx-runtime";
|
|
417
486
|
var lineNumbers = {
|
|
418
487
|
name: "line-numbers",
|
|
419
488
|
Line: (props) => {
|
|
420
489
|
const width = props.totalLines.toString().length + 1;
|
|
421
490
|
return /* @__PURE__ */ jsxs5(Fragment2, {
|
|
422
491
|
children: [
|
|
423
|
-
/* @__PURE__ */
|
|
492
|
+
/* @__PURE__ */ jsx12("span", {
|
|
424
493
|
style: { minWidth: `${width}ch` },
|
|
425
494
|
className: "text-right text-openpkg-code-line-number select-none mr-1",
|
|
426
495
|
children: props.lineNumber
|
|
427
496
|
}),
|
|
428
|
-
/* @__PURE__ */
|
|
497
|
+
/* @__PURE__ */ jsx12(InnerLine6, {
|
|
429
498
|
merge: props
|
|
430
499
|
})
|
|
431
500
|
]
|
|
@@ -434,12 +503,12 @@ var lineNumbers = {
|
|
|
434
503
|
};
|
|
435
504
|
|
|
436
505
|
// src/docskit/link.tsx
|
|
437
|
-
import { jsx as
|
|
506
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
438
507
|
var link = {
|
|
439
508
|
name: "link",
|
|
440
509
|
Inline: ({ annotation, children }) => {
|
|
441
510
|
const { query } = annotation;
|
|
442
|
-
return /* @__PURE__ */
|
|
511
|
+
return /* @__PURE__ */ jsx13("a", {
|
|
443
512
|
href: query,
|
|
444
513
|
className: "underline",
|
|
445
514
|
children
|
|
@@ -448,12 +517,12 @@ var link = {
|
|
|
448
517
|
};
|
|
449
518
|
|
|
450
519
|
// src/docskit/mark.tsx
|
|
451
|
-
import { jsx as
|
|
520
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
452
521
|
var mark = {
|
|
453
522
|
name: "mark",
|
|
454
523
|
Block: ({ annotation, children }) => {
|
|
455
524
|
const color2 = getColor(annotation);
|
|
456
|
-
return /* @__PURE__ */
|
|
525
|
+
return /* @__PURE__ */ jsx14("div", {
|
|
457
526
|
style: {
|
|
458
527
|
["--openpkg-line-bg"]: `rgb(from ${color2} r g b / 0.13)`,
|
|
459
528
|
["--openpkg-line-border"]: color2
|
|
@@ -463,7 +532,7 @@ var mark = {
|
|
|
463
532
|
},
|
|
464
533
|
Inline: ({ annotation, children }) => {
|
|
465
534
|
const color2 = getColor(annotation);
|
|
466
|
-
return /* @__PURE__ */
|
|
535
|
+
return /* @__PURE__ */ jsx14("span", {
|
|
467
536
|
style: {
|
|
468
537
|
boxShadow: `0 0 0 1px rgb(from ${color2} r g b / 0.5)`,
|
|
469
538
|
backgroundColor: `rgb(from ${color2} r g b / 0.13)`
|
|
@@ -481,28 +550,28 @@ var colors = ["var(--ch-5)", "var(--ch-3)", "var(--ch-2)"];
|
|
|
481
550
|
|
|
482
551
|
// src/tooltip/tooltip.tsx
|
|
483
552
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
484
|
-
import { jsx as
|
|
553
|
+
import { jsx as jsx15, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
485
554
|
|
|
486
555
|
function TooltipProvider({
|
|
487
556
|
delayDuration = 0,
|
|
488
557
|
...props
|
|
489
558
|
}) {
|
|
490
|
-
return /* @__PURE__ */
|
|
559
|
+
return /* @__PURE__ */ jsx15(TooltipPrimitive.Provider, {
|
|
491
560
|
"data-slot": "tooltip-provider",
|
|
492
561
|
delayDuration,
|
|
493
562
|
...props
|
|
494
563
|
});
|
|
495
564
|
}
|
|
496
565
|
function Tooltip({ ...props }) {
|
|
497
|
-
return /* @__PURE__ */
|
|
498
|
-
children: /* @__PURE__ */
|
|
566
|
+
return /* @__PURE__ */ jsx15(TooltipProvider, {
|
|
567
|
+
children: /* @__PURE__ */ jsx15(TooltipPrimitive.Root, {
|
|
499
568
|
"data-slot": "tooltip",
|
|
500
569
|
...props
|
|
501
570
|
})
|
|
502
571
|
});
|
|
503
572
|
}
|
|
504
573
|
function TooltipTrigger({ ...props }) {
|
|
505
|
-
return /* @__PURE__ */
|
|
574
|
+
return /* @__PURE__ */ jsx15(TooltipPrimitive.Trigger, {
|
|
506
575
|
"data-slot": "tooltip-trigger",
|
|
507
576
|
...props
|
|
508
577
|
});
|
|
@@ -513,7 +582,7 @@ function TooltipContent({
|
|
|
513
582
|
children,
|
|
514
583
|
...props
|
|
515
584
|
}) {
|
|
516
|
-
return /* @__PURE__ */
|
|
585
|
+
return /* @__PURE__ */ jsx15(TooltipPrimitive.Portal, {
|
|
517
586
|
children: /* @__PURE__ */ jsxs6(TooltipPrimitive.Content, {
|
|
518
587
|
"data-slot": "tooltip-content",
|
|
519
588
|
sideOffset,
|
|
@@ -521,7 +590,7 @@ function TooltipContent({
|
|
|
521
590
|
...props,
|
|
522
591
|
children: [
|
|
523
592
|
children,
|
|
524
|
-
/* @__PURE__ */
|
|
593
|
+
/* @__PURE__ */ jsx15(TooltipPrimitive.Arrow, {
|
|
525
594
|
className: "bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"
|
|
526
595
|
})
|
|
527
596
|
]
|
|
@@ -530,33 +599,33 @@ function TooltipContent({
|
|
|
530
599
|
}
|
|
531
600
|
|
|
532
601
|
// src/docskit/tooltip.client.tsx
|
|
533
|
-
import { jsx as
|
|
602
|
+
import { jsx as jsx16, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
534
603
|
|
|
535
604
|
function NoteTooltip({ children, name }) {
|
|
536
605
|
let note = useNotesContext(name);
|
|
537
606
|
if (!note) {
|
|
538
607
|
note = { name, type: "prose", children: name };
|
|
539
608
|
}
|
|
540
|
-
return /* @__PURE__ */
|
|
609
|
+
return /* @__PURE__ */ jsx16(TooltipProvider, {
|
|
541
610
|
delayDuration: 100,
|
|
542
611
|
children: /* @__PURE__ */ jsxs7(Tooltip, {
|
|
543
612
|
children: [
|
|
544
|
-
/* @__PURE__ */
|
|
613
|
+
/* @__PURE__ */ jsx16(TooltipTrigger, {
|
|
545
614
|
asChild: true,
|
|
546
|
-
children: /* @__PURE__ */
|
|
615
|
+
children: /* @__PURE__ */ jsx16("span", {
|
|
547
616
|
className: "underline decoration-dotted underline-offset-4 cursor-help",
|
|
548
617
|
children
|
|
549
618
|
})
|
|
550
619
|
}),
|
|
551
|
-
note.type === "code" ? /* @__PURE__ */
|
|
620
|
+
note.type === "code" ? /* @__PURE__ */ jsx16(TooltipContent, {
|
|
552
621
|
className: cn("min-w-44 max-w-96 whitespace-normal", "p-0 [&>div]:!my-0 border-none rounded-none bg-transparent", "[&>span>svg]:invisible"),
|
|
553
622
|
children: note?.children
|
|
554
|
-
}) : note.type === "image" ? /* @__PURE__ */
|
|
623
|
+
}) : note.type === "image" ? /* @__PURE__ */ jsx16(TooltipContent, {
|
|
555
624
|
className: cn("min-w-44 max-w-96 whitespace-normal", "p-0 [&>*]:first:mt-0 [&>*]:last:mb-0 border-none bg-transparent", "[&>span>svg]:invisible"),
|
|
556
625
|
children: note?.children
|
|
557
|
-
}) : /* @__PURE__ */
|
|
626
|
+
}) : /* @__PURE__ */ jsx16(TooltipContent, {
|
|
558
627
|
className: cn("min-w-44 max-w-96 whitespace-normal", "p-4"),
|
|
559
|
-
children: /* @__PURE__ */
|
|
628
|
+
children: /* @__PURE__ */ jsx16("div", {
|
|
560
629
|
className: "[&>:first-child]:mt-0 [&>:last-child]:mb-0",
|
|
561
630
|
children: note?.children
|
|
562
631
|
})
|
|
@@ -567,12 +636,12 @@ function NoteTooltip({ children, name }) {
|
|
|
567
636
|
}
|
|
568
637
|
|
|
569
638
|
// src/docskit/tooltip.tsx
|
|
570
|
-
import { jsx as
|
|
639
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
571
640
|
var tooltip = {
|
|
572
641
|
name: "tooltip",
|
|
573
642
|
Inline: ({ children, annotation }) => {
|
|
574
643
|
const { query } = annotation;
|
|
575
|
-
return /* @__PURE__ */
|
|
644
|
+
return /* @__PURE__ */ jsx17(NoteTooltip, {
|
|
576
645
|
name: query,
|
|
577
646
|
children
|
|
578
647
|
});
|
|
@@ -580,7 +649,7 @@ var tooltip = {
|
|
|
580
649
|
};
|
|
581
650
|
function TooltipLink(props) {
|
|
582
651
|
const name = props.href?.slice("tooltip:".length) ?? "";
|
|
583
|
-
return /* @__PURE__ */
|
|
652
|
+
return /* @__PURE__ */ jsx17(NoteTooltip, {
|
|
584
653
|
name,
|
|
585
654
|
children: props.children
|
|
586
655
|
});
|
|
@@ -588,16 +657,16 @@ function TooltipLink(props) {
|
|
|
588
657
|
|
|
589
658
|
// src/docskit/word-wrap.tsx
|
|
590
659
|
import { InnerLine as InnerLine7, InnerPre, InnerToken } from "codehike/code";
|
|
591
|
-
import { jsx as
|
|
660
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
592
661
|
var wordWrap = {
|
|
593
662
|
name: "word-wrap",
|
|
594
|
-
Pre: (props) => /* @__PURE__ */
|
|
663
|
+
Pre: (props) => /* @__PURE__ */ jsx18(InnerPre, {
|
|
595
664
|
merge: props,
|
|
596
665
|
className: "whitespace-pre-wrap"
|
|
597
666
|
}),
|
|
598
|
-
Line: (props) => /* @__PURE__ */
|
|
667
|
+
Line: (props) => /* @__PURE__ */ jsx18(InnerLine7, {
|
|
599
668
|
merge: props,
|
|
600
|
-
children: /* @__PURE__ */
|
|
669
|
+
children: /* @__PURE__ */ jsx18("div", {
|
|
601
670
|
style: {
|
|
602
671
|
textIndent: `${-props.indentation}ch`,
|
|
603
672
|
marginLeft: `${props.indentation}ch`
|
|
@@ -605,7 +674,7 @@ var wordWrap = {
|
|
|
605
674
|
children: props.children
|
|
606
675
|
})
|
|
607
676
|
}),
|
|
608
|
-
Token: (props) => /* @__PURE__ */
|
|
677
|
+
Token: (props) => /* @__PURE__ */ jsx18(InnerToken, {
|
|
609
678
|
merge: props,
|
|
610
679
|
style: { textIndent: 0 }
|
|
611
680
|
})
|
|
@@ -628,12 +697,54 @@ function getHandlers(options) {
|
|
|
628
697
|
].filter(Boolean);
|
|
629
698
|
}
|
|
630
699
|
|
|
700
|
+
// src/docskit/code.icon.tsx
|
|
701
|
+
import { TerminalIcon } from "lucide-react";
|
|
702
|
+
import { themeIcons } from "seti-icons";
|
|
703
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
704
|
+
function CodeIcon({
|
|
705
|
+
title,
|
|
706
|
+
lang,
|
|
707
|
+
className
|
|
708
|
+
}) {
|
|
709
|
+
if (title?.toLowerCase() === "terminal output" || title?.toLowerCase() === "terminal" || lang === "sh" || lang === "shell" || lang === "bash") {
|
|
710
|
+
return /* @__PURE__ */ jsx19(TerminalIcon, {
|
|
711
|
+
size: 16,
|
|
712
|
+
className,
|
|
713
|
+
style: { marginTop: -3.5 }
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
const ext = lang === "rust" ? "rs" : lang === "typescript" ? "ts" : lang;
|
|
717
|
+
const filename = `x.${ext}`;
|
|
718
|
+
const { svg } = getIcon(filename);
|
|
719
|
+
const __html = svg.replace(/svg/, `svg fill='currentColor' style='margin: -4px; height: 24px; width: 24px;'`);
|
|
720
|
+
return /* @__PURE__ */ jsx19("span", {
|
|
721
|
+
className,
|
|
722
|
+
children: /* @__PURE__ */ jsx19("span", {
|
|
723
|
+
dangerouslySetInnerHTML: { __html },
|
|
724
|
+
style: { display: "contents" }
|
|
725
|
+
})
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
var getIcon = themeIcons({
|
|
729
|
+
white: "#d4d7d6",
|
|
730
|
+
grey: "#4d5a5e",
|
|
731
|
+
"grey-light": "#6d8086",
|
|
732
|
+
blue: "#519aba",
|
|
733
|
+
green: "#8dc149",
|
|
734
|
+
orange: "#e37933",
|
|
735
|
+
pink: "#f55385",
|
|
736
|
+
purple: "#a074c4",
|
|
737
|
+
red: "#cc3e44",
|
|
738
|
+
yellow: "#cbcb41",
|
|
739
|
+
ignore: "#41535b"
|
|
740
|
+
});
|
|
741
|
+
|
|
631
742
|
// src/docskit/code.skeleton.tsx
|
|
632
743
|
import { useId } from "react";
|
|
633
|
-
import { jsx as
|
|
744
|
+
import { jsx as jsx20, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
634
745
|
|
|
635
746
|
function SkeletonLine({ width = "75%" }) {
|
|
636
|
-
return /* @__PURE__ */
|
|
747
|
+
return /* @__PURE__ */ jsx20("div", {
|
|
637
748
|
className: "h-4 bg-openpkg-code-border/20 rounded animate-pulse",
|
|
638
749
|
style: { width }
|
|
639
750
|
});
|
|
@@ -650,23 +761,23 @@ function CodeBlockSkeleton({
|
|
|
650
761
|
return /* @__PURE__ */ jsxs8("div", {
|
|
651
762
|
className: "rounded overflow-hidden border border-openpkg-code-border my-4 not-prose",
|
|
652
763
|
children: [
|
|
653
|
-
hasTitle && /* @__PURE__ */
|
|
764
|
+
hasTitle && /* @__PURE__ */ jsx20("div", {
|
|
654
765
|
className: cn("border-b border-openpkg-code-border bg-openpkg-code-header px-3 py-0", "w-full h-9 flex items-center shrink-0"),
|
|
655
766
|
children: /* @__PURE__ */ jsxs8("div", {
|
|
656
767
|
className: "flex items-center h-5 gap-2",
|
|
657
768
|
children: [
|
|
658
|
-
/* @__PURE__ */
|
|
769
|
+
/* @__PURE__ */ jsx20("div", {
|
|
659
770
|
className: "size-4 bg-openpkg-code-border/30 rounded animate-pulse"
|
|
660
771
|
}),
|
|
661
|
-
/* @__PURE__ */
|
|
772
|
+
/* @__PURE__ */ jsx20("div", {
|
|
662
773
|
className: "h-4 w-20 bg-openpkg-code-border/30 rounded animate-pulse"
|
|
663
774
|
})
|
|
664
775
|
]
|
|
665
776
|
})
|
|
666
777
|
}),
|
|
667
|
-
/* @__PURE__ */
|
|
778
|
+
/* @__PURE__ */ jsx20("div", {
|
|
668
779
|
className: "bg-openpkg-code-bg px-4 py-3 space-y-2",
|
|
669
|
-
children: lineWidths.map((width, i) => /* @__PURE__ */
|
|
780
|
+
children: lineWidths.map((width, i) => /* @__PURE__ */ jsx20(SkeletonLine, {
|
|
670
781
|
width
|
|
671
782
|
}, `${id}-line-${i}`))
|
|
672
783
|
})
|
|
@@ -682,26 +793,26 @@ function TerminalSkeleton({ lines = 3 }) {
|
|
|
682
793
|
return /* @__PURE__ */ jsxs8("div", {
|
|
683
794
|
className: "rounded overflow-hidden border border-openpkg-code-border my-4 not-prose",
|
|
684
795
|
children: [
|
|
685
|
-
/* @__PURE__ */
|
|
796
|
+
/* @__PURE__ */ jsx20("div", {
|
|
686
797
|
className: cn("border-b border-openpkg-code-border bg-openpkg-code-header", "w-full h-9 flex items-center justify-center shrink-0", "relative"),
|
|
687
798
|
children: /* @__PURE__ */ jsxs8("div", {
|
|
688
799
|
className: "absolute left-3 flex items-center gap-2",
|
|
689
800
|
children: [
|
|
690
|
-
/* @__PURE__ */
|
|
801
|
+
/* @__PURE__ */ jsx20("div", {
|
|
691
802
|
className: "size-3 rounded-full bg-openpkg-code-text-inactive/30"
|
|
692
803
|
}),
|
|
693
|
-
/* @__PURE__ */
|
|
804
|
+
/* @__PURE__ */ jsx20("div", {
|
|
694
805
|
className: "size-3 rounded-full bg-openpkg-code-text-inactive/30"
|
|
695
806
|
}),
|
|
696
|
-
/* @__PURE__ */
|
|
807
|
+
/* @__PURE__ */ jsx20("div", {
|
|
697
808
|
className: "size-3 rounded-full bg-openpkg-code-text-inactive/30"
|
|
698
809
|
})
|
|
699
810
|
]
|
|
700
811
|
})
|
|
701
812
|
}),
|
|
702
|
-
/* @__PURE__ */
|
|
813
|
+
/* @__PURE__ */ jsx20("div", {
|
|
703
814
|
className: "bg-openpkg-code-bg px-4 py-3 space-y-2",
|
|
704
|
-
children: lineWidths.map((width, i) => /* @__PURE__ */
|
|
815
|
+
children: lineWidths.map((width, i) => /* @__PURE__ */ jsx20(SkeletonLine, {
|
|
705
816
|
width
|
|
706
817
|
}, `${id}-line-${i}`))
|
|
707
818
|
})
|
|
@@ -709,7 +820,7 @@ function TerminalSkeleton({ lines = 3 }) {
|
|
|
709
820
|
});
|
|
710
821
|
}
|
|
711
822
|
function InlineCodeSkeleton() {
|
|
712
|
-
return /* @__PURE__ */
|
|
823
|
+
return /* @__PURE__ */ jsx20("span", {
|
|
713
824
|
className: "inline-block h-5 w-16 bg-openpkg-code-border/20 rounded border border-openpkg-code-border animate-pulse align-middle"
|
|
714
825
|
});
|
|
715
826
|
}
|
|
@@ -722,23 +833,23 @@ function CodeTabsSkeleton({ tabs = 2, lines = 6 }) {
|
|
|
722
833
|
return /* @__PURE__ */ jsxs8("div", {
|
|
723
834
|
className: "rounded overflow-hidden border border-openpkg-code-border my-4 not-prose",
|
|
724
835
|
children: [
|
|
725
|
-
/* @__PURE__ */
|
|
836
|
+
/* @__PURE__ */ jsx20("div", {
|
|
726
837
|
className: cn("border-b border-openpkg-code-border bg-openpkg-code-header px-2 py-0", "w-full h-9 flex items-center shrink-0 gap-1"),
|
|
727
838
|
children: Array.from({ length: tabs }).map((_, i) => /* @__PURE__ */ jsxs8("div", {
|
|
728
839
|
className: "flex items-center gap-1.5 px-3 h-full",
|
|
729
840
|
children: [
|
|
730
|
-
/* @__PURE__ */
|
|
841
|
+
/* @__PURE__ */ jsx20("div", {
|
|
731
842
|
className: "size-4 bg-openpkg-code-border/30 rounded animate-pulse"
|
|
732
843
|
}),
|
|
733
|
-
/* @__PURE__ */
|
|
844
|
+
/* @__PURE__ */ jsx20("div", {
|
|
734
845
|
className: "h-4 w-16 bg-openpkg-code-border/30 rounded animate-pulse"
|
|
735
846
|
})
|
|
736
847
|
]
|
|
737
848
|
}, `${id}-tab-${i}`))
|
|
738
849
|
}),
|
|
739
|
-
/* @__PURE__ */
|
|
850
|
+
/* @__PURE__ */ jsx20("div", {
|
|
740
851
|
className: "bg-openpkg-code-bg px-4 py-3 space-y-2",
|
|
741
|
-
children: lineWidths.map((width, i) => /* @__PURE__ */
|
|
852
|
+
children: lineWidths.map((width, i) => /* @__PURE__ */ jsx20(SkeletonLine, {
|
|
742
853
|
width
|
|
743
854
|
}, `${id}-line-${i}`))
|
|
744
855
|
})
|
|
@@ -746,224 +857,542 @@ function CodeTabsSkeleton({ tabs = 2, lines = 6 }) {
|
|
|
746
857
|
});
|
|
747
858
|
}
|
|
748
859
|
|
|
749
|
-
// src/docskit/
|
|
750
|
-
import
|
|
751
|
-
import
|
|
752
|
-
import { jsx as jsx19, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
860
|
+
// src/docskit/tabs.tsx
|
|
861
|
+
import * as TabsPrimitive from "@radix-ui/react-tabs";
|
|
862
|
+
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
753
863
|
|
|
754
|
-
function
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
})
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
864
|
+
function Tabs({ className, ...props }) {
|
|
865
|
+
return /* @__PURE__ */ jsx21(TabsPrimitive.Root, {
|
|
866
|
+
"data-slot": "tabs",
|
|
867
|
+
className: cn("flex flex-col gap-2", className),
|
|
868
|
+
...props
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
function TabsList({ className, ...props }) {
|
|
872
|
+
return /* @__PURE__ */ jsx21(TabsPrimitive.List, {
|
|
873
|
+
"data-slot": "tabs-list",
|
|
874
|
+
className: cn("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]", className),
|
|
875
|
+
...props
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
function TabsTrigger({ className, ...props }) {
|
|
879
|
+
return /* @__PURE__ */ jsx21(TabsPrimitive.Trigger, {
|
|
880
|
+
"data-slot": "tabs-trigger",
|
|
881
|
+
className: cn("dark:data-[state=active]:text-foreground focus-visible:ring-ring/50 focus-visible:outline-ring dark:text-muted-foreground inline-flex h-full flex-1 items-center justify-center gap-1.5 px-2 py-1 text-sm font-normal whitespace-nowrap transition-colors focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
|
|
882
|
+
...props
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
function TabsContent({ className, ...props }) {
|
|
886
|
+
return /* @__PURE__ */ jsx21(TabsPrimitive.Content, {
|
|
887
|
+
"data-slot": "tabs-content",
|
|
888
|
+
className: cn("flex-1 outline-none", className),
|
|
889
|
+
...props
|
|
890
|
+
});
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
// src/docskit/code.client-highlight.tsx
|
|
894
|
+
import { jsx as jsx22, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
895
|
+
|
|
896
|
+
function ClientDocsKitCode(props) {
|
|
897
|
+
const { codeblock, handlers: extraHandlers, className: wrapperClassName } = props;
|
|
898
|
+
const [highlighted, setHighlighted] = useState3(null);
|
|
899
|
+
const { title, flags } = extractFlags(codeblock);
|
|
900
|
+
const options = flagsToOptions(flags);
|
|
901
|
+
useEffect(() => {
|
|
902
|
+
let cancelled = false;
|
|
903
|
+
highlight({ ...codeblock, lang: codeblock.lang || "txt" }, theme).then((result) => {
|
|
904
|
+
if (!cancelled)
|
|
905
|
+
setHighlighted(result);
|
|
906
|
+
});
|
|
907
|
+
return () => {
|
|
908
|
+
cancelled = true;
|
|
768
909
|
};
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
910
|
+
}, [codeblock.value, codeblock.lang, codeblock.meta]);
|
|
911
|
+
if (!highlighted) {
|
|
912
|
+
return /* @__PURE__ */ jsx22(CodeBlockSkeleton, {
|
|
913
|
+
hasTitle: !!title
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
const handlers = getHandlers(options);
|
|
917
|
+
if (extraHandlers) {
|
|
918
|
+
handlers.push(...extraHandlers);
|
|
919
|
+
}
|
|
920
|
+
const { background: _background, ...highlightedStyle } = highlighted.style;
|
|
921
|
+
const showCopy = options?.copyButton;
|
|
922
|
+
const icon2 = /* @__PURE__ */ jsx22(CodeIcon, {
|
|
923
|
+
title,
|
|
924
|
+
lang: codeblock.lang,
|
|
925
|
+
className: "opacity-60"
|
|
926
|
+
});
|
|
772
927
|
return /* @__PURE__ */ jsxs9("div", {
|
|
773
|
-
|
|
774
|
-
className: cn("relative", className),
|
|
928
|
+
className: cn("group rounded overflow-hidden relative border-openpkg-code-border flex flex-col border my-4 not-prose", wrapperClassName),
|
|
775
929
|
children: [
|
|
776
|
-
/* @__PURE__ */
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
930
|
+
title ? /* @__PURE__ */ jsx22("div", {
|
|
931
|
+
className: cn("border-b-[1px] border-openpkg-code-border bg-openpkg-code-header px-3 py-0", "w-full h-9 flex items-center shrink-0", "text-openpkg-code-text-inactive text-sm font-mono"),
|
|
932
|
+
children: /* @__PURE__ */ jsxs9("div", {
|
|
933
|
+
className: "flex items-center h-5 gap-2",
|
|
934
|
+
children: [
|
|
935
|
+
/* @__PURE__ */ jsx22("div", {
|
|
936
|
+
className: "size-4",
|
|
937
|
+
children: icon2
|
|
938
|
+
}),
|
|
939
|
+
/* @__PURE__ */ jsx22("span", {
|
|
940
|
+
className: "leading-none",
|
|
941
|
+
children: title
|
|
942
|
+
})
|
|
943
|
+
]
|
|
944
|
+
})
|
|
945
|
+
}) : null,
|
|
946
|
+
/* @__PURE__ */ jsxs9("div", {
|
|
947
|
+
className: "relative flex items-start",
|
|
780
948
|
children: [
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
949
|
+
/* @__PURE__ */ jsx22(Pre, {
|
|
950
|
+
code: highlighted,
|
|
951
|
+
className: "overflow-auto px-0 py-3 m-0 rounded-none !bg-openpkg-code-bg selection:bg-openpkg-code-selection selection:text-current max-h-full flex-1",
|
|
952
|
+
style: highlightedStyle,
|
|
953
|
+
handlers
|
|
954
|
+
}),
|
|
955
|
+
showCopy && /* @__PURE__ */ jsx22(CopyButton, {
|
|
956
|
+
text: highlighted.code,
|
|
957
|
+
variant: "floating",
|
|
958
|
+
className: cn("absolute right-3 z-10 text-openpkg-code-text-inactive", "top-3")
|
|
785
959
|
})
|
|
786
960
|
]
|
|
787
|
-
}),
|
|
788
|
-
open && /* @__PURE__ */ jsx19("div", {
|
|
789
|
-
className: cn("absolute top-full left-0 mt-1 z-50 min-w-[120px]", "bg-popover border border-border rounded-md shadow-lg overflow-hidden"),
|
|
790
|
-
children: languages.map((lang) => /* @__PURE__ */ jsx19("button", {
|
|
791
|
-
type: "button",
|
|
792
|
-
onClick: () => {
|
|
793
|
-
onChange(lang.id);
|
|
794
|
-
setOpen(false);
|
|
795
|
-
},
|
|
796
|
-
className: cn("w-full px-3 py-2 text-sm text-left transition-colors cursor-pointer", lang.id === value ? "bg-primary/10 text-primary" : "text-foreground hover:bg-muted"),
|
|
797
|
-
children: lang.label
|
|
798
|
-
}, lang.id))
|
|
799
961
|
})
|
|
800
962
|
]
|
|
801
963
|
});
|
|
802
964
|
}
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
import { jsx as jsx20, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
806
|
-
|
|
807
|
-
function APICodePanel({
|
|
808
|
-
languages,
|
|
809
|
-
examples,
|
|
810
|
-
externalLink,
|
|
811
|
-
title,
|
|
812
|
-
className
|
|
813
|
-
}) {
|
|
814
|
-
const [selectedLang, setSelectedLang] = useState3(examples[0]?.languageId ?? languages[0]?.id);
|
|
815
|
-
const [copied, setCopied] = useState3(false);
|
|
965
|
+
function ClientTerminal(props) {
|
|
966
|
+
const { codeblock, handlers: extraHandlers } = props;
|
|
816
967
|
const [highlighted, setHighlighted] = useState3(null);
|
|
817
|
-
const
|
|
818
|
-
const
|
|
819
|
-
|
|
820
|
-
useEffect2(() => {
|
|
968
|
+
const { flags } = extractFlagsSimple(codeblock);
|
|
969
|
+
const options = flagsToOptions(flags);
|
|
970
|
+
useEffect(() => {
|
|
821
971
|
let cancelled = false;
|
|
822
|
-
highlight({
|
|
823
|
-
|
|
824
|
-
lang: lang === "curl" ? "bash" : lang,
|
|
825
|
-
meta: ""
|
|
826
|
-
}, theme).then((result) => {
|
|
827
|
-
if (!cancelled) {
|
|
972
|
+
highlight({ ...codeblock, lang: codeblock.lang || "bash" }, theme).then((result) => {
|
|
973
|
+
if (!cancelled)
|
|
828
974
|
setHighlighted(result);
|
|
829
|
-
}
|
|
830
975
|
});
|
|
831
976
|
return () => {
|
|
832
977
|
cancelled = true;
|
|
833
978
|
};
|
|
834
|
-
}, [
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
979
|
+
}, [codeblock.value, codeblock.lang, codeblock.meta]);
|
|
980
|
+
if (!highlighted) {
|
|
981
|
+
return /* @__PURE__ */ jsx22(TerminalSkeleton, {});
|
|
982
|
+
}
|
|
983
|
+
const handlers = getHandlers(options);
|
|
984
|
+
if (extraHandlers) {
|
|
985
|
+
handlers.push(...extraHandlers);
|
|
986
|
+
}
|
|
987
|
+
const { background: _background, ...highlightedStyle } = highlighted.style;
|
|
988
|
+
const showCopy = options?.copyButton;
|
|
989
|
+
const isMultiLine = highlighted.code.includes(`
|
|
990
|
+
`);
|
|
991
|
+
return /* @__PURE__ */ jsxs9("div", {
|
|
992
|
+
className: "group rounded overflow-hidden relative border-openpkg-code-border flex flex-col border my-4 not-prose",
|
|
993
|
+
children: [
|
|
994
|
+
/* @__PURE__ */ jsxs9("div", {
|
|
995
|
+
className: cn("border-b border-openpkg-code-border bg-openpkg-code-header", "w-full h-9 flex items-center justify-center shrink-0", "relative"),
|
|
996
|
+
children: [
|
|
997
|
+
/* @__PURE__ */ jsxs9("div", {
|
|
998
|
+
className: "absolute left-3 flex items-center gap-2",
|
|
999
|
+
children: [
|
|
1000
|
+
/* @__PURE__ */ jsx22("div", {
|
|
1001
|
+
className: "size-3 rounded-full bg-openpkg-code-text-inactive/30"
|
|
1002
|
+
}),
|
|
1003
|
+
/* @__PURE__ */ jsx22("div", {
|
|
1004
|
+
className: "size-3 rounded-full bg-openpkg-code-text-inactive/30"
|
|
855
1005
|
}),
|
|
856
|
-
|
|
857
|
-
className: "
|
|
858
|
-
children: title
|
|
1006
|
+
/* @__PURE__ */ jsx22("div", {
|
|
1007
|
+
className: "size-3 rounded-full bg-openpkg-code-text-inactive/30"
|
|
859
1008
|
})
|
|
860
1009
|
]
|
|
861
1010
|
}),
|
|
862
|
-
/* @__PURE__ */
|
|
863
|
-
className: "
|
|
1011
|
+
/* @__PURE__ */ jsx22("span", {
|
|
1012
|
+
className: "sr-only",
|
|
1013
|
+
children: "Terminal window"
|
|
1014
|
+
})
|
|
1015
|
+
]
|
|
1016
|
+
}),
|
|
1017
|
+
/* @__PURE__ */ jsxs9("div", {
|
|
1018
|
+
className: "relative flex items-start",
|
|
1019
|
+
children: [
|
|
1020
|
+
/* @__PURE__ */ jsx22(Pre, {
|
|
1021
|
+
code: highlighted,
|
|
1022
|
+
className: "overflow-auto px-0 py-3 m-0 rounded-none !bg-openpkg-code-bg selection:bg-openpkg-code-selection selection:text-current max-h-full flex-1",
|
|
1023
|
+
style: highlightedStyle,
|
|
1024
|
+
handlers
|
|
1025
|
+
}),
|
|
1026
|
+
showCopy && /* @__PURE__ */ jsx22(CopyButton, {
|
|
1027
|
+
text: highlighted.code,
|
|
1028
|
+
variant: "floating",
|
|
1029
|
+
className: cn("absolute right-3 z-10 text-openpkg-code-text-inactive", isMultiLine ? "top-3" : "top-1/2 -translate-y-1/2")
|
|
1030
|
+
})
|
|
1031
|
+
]
|
|
1032
|
+
})
|
|
1033
|
+
]
|
|
1034
|
+
});
|
|
1035
|
+
}
|
|
1036
|
+
function ClientInlineCode({ codeblock }) {
|
|
1037
|
+
const [highlighted, setHighlighted] = useState3(null);
|
|
1038
|
+
useEffect(() => {
|
|
1039
|
+
let cancelled = false;
|
|
1040
|
+
highlight(codeblock, theme).then((result) => {
|
|
1041
|
+
if (!cancelled)
|
|
1042
|
+
setHighlighted(result);
|
|
1043
|
+
});
|
|
1044
|
+
return () => {
|
|
1045
|
+
cancelled = true;
|
|
1046
|
+
};
|
|
1047
|
+
}, [codeblock.value, codeblock.lang, codeblock.meta]);
|
|
1048
|
+
if (!highlighted) {
|
|
1049
|
+
return /* @__PURE__ */ jsx22(InlineCodeSkeleton, {});
|
|
1050
|
+
}
|
|
1051
|
+
return /* @__PURE__ */ jsx22(Inline, {
|
|
1052
|
+
code: highlighted,
|
|
1053
|
+
className: "selection:bg-openpkg-code-selection selection:text-current rounded border border-openpkg-code-border px-1 py-0.5 whitespace-nowrap !bg-openpkg-code-bg",
|
|
1054
|
+
style: highlighted.style
|
|
1055
|
+
});
|
|
1056
|
+
}
|
|
1057
|
+
function extractFlags(codeblock) {
|
|
1058
|
+
const meta = codeblock.meta || "";
|
|
1059
|
+
const flags = meta.split(" ").filter((flag) => flag.startsWith("-"))[0] ?? "";
|
|
1060
|
+
const metaWithoutFlags = !flags ? meta : meta === flags ? "" : meta.replace(` ${flags}`, "").trim();
|
|
1061
|
+
const title = metaWithoutFlags.trim();
|
|
1062
|
+
return { title, flags: flags.slice(1) };
|
|
1063
|
+
}
|
|
1064
|
+
function extractFlagsSimple(codeblock) {
|
|
1065
|
+
const meta = codeblock.meta || "";
|
|
1066
|
+
const flagMatch = meta.split(" ").find((flag) => flag.startsWith("-"));
|
|
1067
|
+
const flags = flagMatch ? flagMatch.slice(1) : "";
|
|
1068
|
+
return { flags };
|
|
1069
|
+
}
|
|
1070
|
+
function ClientCode(props) {
|
|
1071
|
+
const { codeblocks, flags: groupFlags, storage } = props;
|
|
1072
|
+
const [highlighted, setHighlighted] = useState3(null);
|
|
1073
|
+
const groupOptions = flagsToOptions(groupFlags?.startsWith("-") ? groupFlags.slice(1) : groupFlags);
|
|
1074
|
+
const _codeBlocksKey = codeblocks.map((b) => `${b.value}|${b.lang}|${b.meta}`).join("::");
|
|
1075
|
+
useEffect(() => {
|
|
1076
|
+
let cancelled = false;
|
|
1077
|
+
Promise.all(codeblocks.map(async (block, index) => {
|
|
1078
|
+
const { title, flags } = extractFlags(block);
|
|
1079
|
+
const tabOptions = flagsToOptions(flags);
|
|
1080
|
+
const options = { ...groupOptions, ...tabOptions };
|
|
1081
|
+
const result = await highlight({ ...block, lang: block.lang || "txt" }, theme);
|
|
1082
|
+
return {
|
|
1083
|
+
index,
|
|
1084
|
+
highlighted: result,
|
|
1085
|
+
title,
|
|
1086
|
+
options,
|
|
1087
|
+
icon: /* @__PURE__ */ jsx22(CodeIcon, {
|
|
1088
|
+
title,
|
|
1089
|
+
lang: block.lang,
|
|
1090
|
+
className: "opacity-60"
|
|
1091
|
+
})
|
|
1092
|
+
};
|
|
1093
|
+
})).then((results) => {
|
|
1094
|
+
if (!cancelled) {
|
|
1095
|
+
const map = new Map;
|
|
1096
|
+
results.forEach((r) => map.set(r.index, r));
|
|
1097
|
+
setHighlighted(map);
|
|
1098
|
+
}
|
|
1099
|
+
});
|
|
1100
|
+
return () => {
|
|
1101
|
+
cancelled = true;
|
|
1102
|
+
};
|
|
1103
|
+
}, [_codeBlocksKey]);
|
|
1104
|
+
if (!highlighted) {
|
|
1105
|
+
return /* @__PURE__ */ jsx22(CodeTabsSkeleton, {
|
|
1106
|
+
tabs: codeblocks.length
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
if (codeblocks.length === 1) {
|
|
1110
|
+
const tab = highlighted.get(0);
|
|
1111
|
+
const handlers = getHandlers(tab.options);
|
|
1112
|
+
const { background: _background, ...highlightedStyle } = tab.highlighted.style;
|
|
1113
|
+
return /* @__PURE__ */ jsxs9("div", {
|
|
1114
|
+
className: "group rounded overflow-hidden relative border-openpkg-code-border flex flex-col border my-4 not-prose",
|
|
1115
|
+
children: [
|
|
1116
|
+
tab.title ? /* @__PURE__ */ jsx22("div", {
|
|
1117
|
+
className: cn("border-b-[1px] border-openpkg-code-border bg-openpkg-code-header px-3 py-0", "w-full h-9 flex items-center shrink-0", "text-openpkg-code-text-inactive text-sm font-mono"),
|
|
1118
|
+
children: /* @__PURE__ */ jsxs9("div", {
|
|
1119
|
+
className: "flex items-center h-5 gap-2",
|
|
864
1120
|
children: [
|
|
865
|
-
/* @__PURE__ */
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
className: "p-1.5 rounded text-openpkg-code-text-inactive hover:text-gray-200 transition-colors cursor-pointer",
|
|
869
|
-
"aria-label": "Copy code",
|
|
870
|
-
children: copied ? /* @__PURE__ */ jsx20(Check, {
|
|
871
|
-
size: 16
|
|
872
|
-
}) : /* @__PURE__ */ jsx20(Copy, {
|
|
873
|
-
size: 16
|
|
874
|
-
})
|
|
1121
|
+
/* @__PURE__ */ jsx22("div", {
|
|
1122
|
+
className: "size-4",
|
|
1123
|
+
children: tab.icon
|
|
875
1124
|
}),
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
rel: "noopener noreferrer",
|
|
880
|
-
className: "p-1.5 rounded text-openpkg-code-text-inactive hover:text-gray-200 transition-colors",
|
|
881
|
-
"aria-label": "Open in playground",
|
|
882
|
-
children: /* @__PURE__ */ jsx20(ExternalLink, {
|
|
883
|
-
size: 16
|
|
884
|
-
})
|
|
1125
|
+
/* @__PURE__ */ jsx22("span", {
|
|
1126
|
+
className: "leading-none",
|
|
1127
|
+
children: tab.title
|
|
885
1128
|
})
|
|
886
1129
|
]
|
|
887
1130
|
})
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
1131
|
+
}) : null,
|
|
1132
|
+
/* @__PURE__ */ jsxs9("div", {
|
|
1133
|
+
className: "relative flex items-start",
|
|
1134
|
+
children: [
|
|
1135
|
+
/* @__PURE__ */ jsx22(Pre, {
|
|
1136
|
+
code: tab.highlighted,
|
|
1137
|
+
className: "overflow-auto px-0 py-3 m-0 rounded-none !bg-openpkg-code-bg selection:bg-openpkg-code-selection selection:text-current max-h-full flex-1",
|
|
1138
|
+
style: highlightedStyle,
|
|
1139
|
+
handlers
|
|
1140
|
+
}),
|
|
1141
|
+
tab.options.copyButton && /* @__PURE__ */ jsx22(CopyButton, {
|
|
1142
|
+
text: tab.highlighted.code,
|
|
1143
|
+
variant: "floating",
|
|
1144
|
+
className: "absolute right-3 top-3 z-10 text-openpkg-code-text-inactive"
|
|
1145
|
+
})
|
|
1146
|
+
]
|
|
900
1147
|
})
|
|
1148
|
+
]
|
|
1149
|
+
});
|
|
1150
|
+
}
|
|
1151
|
+
return /* @__PURE__ */ jsx22(ClientMultiCode, {
|
|
1152
|
+
highlighted,
|
|
1153
|
+
groupOptions,
|
|
1154
|
+
storage
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1157
|
+
function ClientMultiCode({
|
|
1158
|
+
highlighted,
|
|
1159
|
+
groupOptions,
|
|
1160
|
+
storage
|
|
1161
|
+
}) {
|
|
1162
|
+
const tabs = Array.from(highlighted.values());
|
|
1163
|
+
const [storedTitle, setCurrentTitle] = useStateOrLocalStorage(storage, tabs[0].title);
|
|
1164
|
+
const current = tabs.find((tab) => tab.title === storedTitle) || tabs[0];
|
|
1165
|
+
const handlers = getHandlers(current.options);
|
|
1166
|
+
const { background: _background, ...highlightedStyle } = current.highlighted.style;
|
|
1167
|
+
return /* @__PURE__ */ jsxs9(Tabs, {
|
|
1168
|
+
value: current.title,
|
|
1169
|
+
onValueChange: setCurrentTitle,
|
|
1170
|
+
className: cn("group border rounded selection:bg-openpkg-code-selection selection:text-current border-openpkg-code-border overflow-hidden relative flex flex-col max-h-full min-h-0 my-4 gap-0 not-prose"),
|
|
1171
|
+
children: [
|
|
1172
|
+
/* @__PURE__ */ jsx22(TabsList, {
|
|
1173
|
+
className: cn("border-b border-openpkg-code-border bg-openpkg-code-header w-full h-9 min-h-9 shrink-0", "rounded-none p-0 m-0 justify-start items-stretch"),
|
|
1174
|
+
children: tabs.map(({ icon: icon2, title }) => /* @__PURE__ */ jsxs9(TabsTrigger, {
|
|
1175
|
+
value: title,
|
|
1176
|
+
className: cn("rounded-none transition-colors duration-200 gap-1.5 px-3 font-mono justify-start grow-0", "border-r border-openpkg-code-border", "text-openpkg-code-text-inactive data-[state=active]:text-openpkg-code-text-active hover:text-openpkg-code-text-active", "data-[state=active]:bg-openpkg-code-bg/50"),
|
|
1177
|
+
children: [
|
|
1178
|
+
/* @__PURE__ */ jsx22("div", {
|
|
1179
|
+
children: icon2
|
|
1180
|
+
}),
|
|
1181
|
+
/* @__PURE__ */ jsx22("span", {
|
|
1182
|
+
className: "leading-none",
|
|
1183
|
+
children: title
|
|
1184
|
+
})
|
|
1185
|
+
]
|
|
1186
|
+
}, title))
|
|
1187
|
+
}),
|
|
1188
|
+
/* @__PURE__ */ jsxs9(TabsContent, {
|
|
1189
|
+
value: current.title,
|
|
1190
|
+
className: "relative min-h-0 mt-0 flex flex-col",
|
|
1191
|
+
children: [
|
|
1192
|
+
/* @__PURE__ */ jsx22(Pre, {
|
|
1193
|
+
code: current.highlighted,
|
|
1194
|
+
className: "overflow-auto px-0 py-3 m-0 rounded-none !bg-openpkg-code-bg selection:bg-openpkg-code-selection selection:text-current max-h-full flex-1",
|
|
1195
|
+
style: highlightedStyle,
|
|
1196
|
+
handlers
|
|
1197
|
+
}),
|
|
1198
|
+
groupOptions.copyButton && /* @__PURE__ */ jsx22(CopyButton, {
|
|
1199
|
+
text: current.highlighted.code,
|
|
1200
|
+
variant: "floating",
|
|
1201
|
+
className: "absolute right-3 top-3 z-10 text-openpkg-code-text-inactive"
|
|
1202
|
+
})
|
|
1203
|
+
]
|
|
901
1204
|
})
|
|
902
1205
|
]
|
|
903
1206
|
});
|
|
904
1207
|
}
|
|
905
|
-
// src/docskit/api/api-reference-page.tsx
|
|
906
|
-
import { jsx as jsx21, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
907
1208
|
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
1209
|
+
// src/docskit/api/language-selector.tsx
|
|
1210
|
+
import { ChevronDown } from "lucide-react";
|
|
1211
|
+
import * as React3 from "react";
|
|
1212
|
+
import { jsx as jsx23, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1213
|
+
|
|
1214
|
+
function LanguageSelector({
|
|
1215
|
+
languages,
|
|
1216
|
+
value,
|
|
1217
|
+
onChange,
|
|
912
1218
|
className
|
|
913
1219
|
}) {
|
|
914
|
-
|
|
915
|
-
|
|
1220
|
+
const [open, setOpen] = React3.useState(false);
|
|
1221
|
+
const containerRef = React3.useRef(null);
|
|
1222
|
+
const selectedLanguage = languages.find((l) => l.id === value);
|
|
1223
|
+
React3.useEffect(() => {
|
|
1224
|
+
const handleClickOutside = (e) => {
|
|
1225
|
+
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
1226
|
+
setOpen(false);
|
|
1227
|
+
}
|
|
1228
|
+
};
|
|
1229
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
1230
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
1231
|
+
}, []);
|
|
1232
|
+
return /* @__PURE__ */ jsxs10("div", {
|
|
1233
|
+
ref: containerRef,
|
|
1234
|
+
className: cn("relative", className),
|
|
916
1235
|
children: [
|
|
917
|
-
/* @__PURE__ */
|
|
918
|
-
|
|
1236
|
+
/* @__PURE__ */ jsxs10("button", {
|
|
1237
|
+
type: "button",
|
|
1238
|
+
onClick: () => setOpen(!open),
|
|
1239
|
+
className: cn("flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-sm font-medium", "bg-muted/50 hover:bg-muted text-foreground transition-colors cursor-pointer"),
|
|
919
1240
|
children: [
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
description && /* @__PURE__ */ jsx21("div", {
|
|
925
|
-
className: "mt-4 text-lg text-muted-foreground prose prose-lg dark:prose-invert max-w-none",
|
|
926
|
-
children: description
|
|
1241
|
+
selectedLanguage?.label ?? value,
|
|
1242
|
+
/* @__PURE__ */ jsx23(ChevronDown, {
|
|
1243
|
+
size: 14,
|
|
1244
|
+
className: cn("transition-transform", open && "rotate-180")
|
|
927
1245
|
})
|
|
928
1246
|
]
|
|
929
1247
|
}),
|
|
930
|
-
/* @__PURE__ */
|
|
931
|
-
|
|
1248
|
+
open && /* @__PURE__ */ jsx23("div", {
|
|
1249
|
+
className: cn("absolute top-full left-0 mt-1 z-50 min-w-[120px]", "bg-popover border border-border rounded-md shadow-lg overflow-hidden"),
|
|
1250
|
+
children: languages.map((lang) => /* @__PURE__ */ jsx23("button", {
|
|
1251
|
+
type: "button",
|
|
1252
|
+
onClick: () => {
|
|
1253
|
+
onChange(lang.id);
|
|
1254
|
+
setOpen(false);
|
|
1255
|
+
},
|
|
1256
|
+
className: cn("w-full px-3 py-2 text-sm text-left transition-colors cursor-pointer", lang.id === value ? "bg-primary/10 text-primary" : "text-foreground hover:bg-muted"),
|
|
1257
|
+
children: lang.label
|
|
1258
|
+
}, lang.id))
|
|
932
1259
|
})
|
|
933
1260
|
]
|
|
934
1261
|
});
|
|
935
1262
|
}
|
|
936
|
-
// src/docskit/api/api-section.tsx
|
|
937
|
-
import { jsx as jsx22, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
938
1263
|
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
children,
|
|
1264
|
+
// src/docskit/api/api-code-panel.tsx
|
|
1265
|
+
import { jsx as jsx24, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1266
|
+
|
|
1267
|
+
function APICodePanel({
|
|
944
1268
|
languages,
|
|
945
1269
|
examples,
|
|
946
1270
|
externalLink,
|
|
947
|
-
|
|
1271
|
+
title,
|
|
948
1272
|
className
|
|
949
1273
|
}) {
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
1274
|
+
const [selectedLang, setSelectedLang] = useState5(examples[0]?.languageId ?? languages[0]?.id);
|
|
1275
|
+
const currentExample = examples.find((e) => e.languageId === selectedLang);
|
|
1276
|
+
const code = currentExample?.code ?? "";
|
|
1277
|
+
const lang = currentExample?.highlightLang ?? currentExample?.languageId ?? "txt";
|
|
1278
|
+
const metaTitle = title ?? "";
|
|
1279
|
+
const meta = metaTitle ? `${metaTitle} -c` : "-c";
|
|
1280
|
+
return /* @__PURE__ */ jsxs11("div", {
|
|
1281
|
+
className: cn("sticky top-20", className),
|
|
1282
|
+
children: [
|
|
1283
|
+
languages.length > 1 && /* @__PURE__ */ jsx24("div", {
|
|
1284
|
+
className: "flex items-center gap-2 mb-2",
|
|
1285
|
+
children: /* @__PURE__ */ jsx24(LanguageSelector, {
|
|
1286
|
+
languages,
|
|
1287
|
+
value: selectedLang,
|
|
1288
|
+
onChange: setSelectedLang
|
|
1289
|
+
})
|
|
1290
|
+
}),
|
|
1291
|
+
/* @__PURE__ */ jsx24(ClientDocsKitCode, {
|
|
1292
|
+
codeblock: {
|
|
1293
|
+
value: code,
|
|
1294
|
+
lang: lang === "curl" ? "bash" : lang,
|
|
1295
|
+
meta
|
|
1296
|
+
}
|
|
1297
|
+
})
|
|
1298
|
+
]
|
|
1299
|
+
});
|
|
1300
|
+
}
|
|
1301
|
+
// src/docskit/api/api-reference-layout.tsx
|
|
1302
|
+
import { jsx as jsx25, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1303
|
+
|
|
1304
|
+
function APIReferenceLayout({
|
|
1305
|
+
children,
|
|
1306
|
+
examples,
|
|
1307
|
+
className,
|
|
1308
|
+
leftWidth = "58%",
|
|
1309
|
+
rightWidth = "42%"
|
|
1310
|
+
}) {
|
|
1311
|
+
return /* @__PURE__ */ jsxs12("div", {
|
|
1312
|
+
className: cn("openpkg-api-layout", "max-w-[1600px] mx-auto", "flex flex-col", "lg:grid", className),
|
|
1313
|
+
style: {
|
|
1314
|
+
"--openpkg-left-width": leftWidth,
|
|
1315
|
+
"--openpkg-right-width": rightWidth
|
|
1316
|
+
},
|
|
1317
|
+
children: [
|
|
1318
|
+
/* @__PURE__ */ jsx25("div", {
|
|
1319
|
+
className: cn("openpkg-api-layout-left", "py-8 px-4", "sm:py-10 sm:px-6", "lg:py-12 lg:px-12 lg:pl-16", "lg:border-r lg:border-[var(--openpkg-border-subtle)]", "bg-[var(--openpkg-bg-root)]", "openpkg-animate-fade-in"),
|
|
1320
|
+
style: { gridColumn: "1" },
|
|
1321
|
+
children
|
|
1322
|
+
}),
|
|
1323
|
+
/* @__PURE__ */ jsx25("div", {
|
|
1324
|
+
className: cn("openpkg-api-layout-right", "border-t border-[var(--openpkg-border-subtle)] lg:border-t-0", "py-8 px-4", "sm:py-10 sm:px-6", "lg:sticky lg:top-0 lg:h-screen lg:overflow-y-auto", "lg:py-12 lg:px-12 lg:pl-8", "bg-[var(--openpkg-bg-root)]", "openpkg-animate-fade-in"),
|
|
1325
|
+
style: {
|
|
1326
|
+
gridColumn: "2",
|
|
1327
|
+
animationDelay: "100ms"
|
|
1328
|
+
},
|
|
1329
|
+
children: examples
|
|
1330
|
+
})
|
|
1331
|
+
]
|
|
1332
|
+
});
|
|
1333
|
+
}
|
|
1334
|
+
// src/docskit/api/api-reference-page.tsx
|
|
1335
|
+
import { jsx as jsx26, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1336
|
+
|
|
1337
|
+
function APIReferencePage({
|
|
1338
|
+
title,
|
|
1339
|
+
description,
|
|
1340
|
+
children,
|
|
1341
|
+
className
|
|
1342
|
+
}) {
|
|
1343
|
+
return /* @__PURE__ */ jsxs13("div", {
|
|
1344
|
+
className: cn("max-w-7xl mx-auto px-4 sm:px-6 lg:px-8", className),
|
|
1345
|
+
children: [
|
|
1346
|
+
/* @__PURE__ */ jsxs13("header", {
|
|
1347
|
+
className: "py-8 border-b border-border",
|
|
1348
|
+
children: [
|
|
1349
|
+
/* @__PURE__ */ jsx26("h1", {
|
|
1350
|
+
className: "text-3xl font-bold text-foreground",
|
|
1351
|
+
children: title
|
|
1352
|
+
}),
|
|
1353
|
+
description && /* @__PURE__ */ jsx26("div", {
|
|
1354
|
+
className: "mt-4 text-lg text-muted-foreground prose prose-lg dark:prose-invert max-w-none",
|
|
1355
|
+
children: description
|
|
1356
|
+
})
|
|
1357
|
+
]
|
|
1358
|
+
}),
|
|
1359
|
+
/* @__PURE__ */ jsx26("div", {
|
|
1360
|
+
children
|
|
1361
|
+
})
|
|
1362
|
+
]
|
|
1363
|
+
});
|
|
1364
|
+
}
|
|
1365
|
+
// src/docskit/api/api-section.tsx
|
|
1366
|
+
import { jsx as jsx27, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1367
|
+
|
|
1368
|
+
function APISection({
|
|
1369
|
+
title,
|
|
1370
|
+
id,
|
|
1371
|
+
description,
|
|
1372
|
+
children,
|
|
1373
|
+
languages,
|
|
1374
|
+
examples,
|
|
1375
|
+
externalLink,
|
|
1376
|
+
codePanelTitle,
|
|
1377
|
+
className
|
|
1378
|
+
}) {
|
|
1379
|
+
return /* @__PURE__ */ jsx27("section", {
|
|
1380
|
+
id,
|
|
1381
|
+
className: cn("py-8 border-b border-border last:border-b-0", className),
|
|
1382
|
+
children: /* @__PURE__ */ jsxs14("div", {
|
|
1383
|
+
className: "grid grid-cols-1 lg:grid-cols-2 gap-8 lg:gap-12",
|
|
1384
|
+
children: [
|
|
1385
|
+
/* @__PURE__ */ jsxs14("div", {
|
|
1386
|
+
className: "space-y-6",
|
|
1387
|
+
children: [
|
|
1388
|
+
/* @__PURE__ */ jsxs14("div", {
|
|
1389
|
+
children: [
|
|
1390
|
+
/* @__PURE__ */ jsx27("h2", {
|
|
1391
|
+
className: "text-2xl font-semibold text-foreground",
|
|
1392
|
+
children: title
|
|
1393
|
+
}),
|
|
1394
|
+
description && /* @__PURE__ */ jsx27("div", {
|
|
1395
|
+
className: "mt-3 text-muted-foreground prose prose-sm dark:prose-invert",
|
|
967
1396
|
children: description
|
|
968
1397
|
})
|
|
969
1398
|
]
|
|
@@ -971,9 +1400,9 @@ function APISection({
|
|
|
971
1400
|
children
|
|
972
1401
|
]
|
|
973
1402
|
}),
|
|
974
|
-
/* @__PURE__ */
|
|
1403
|
+
/* @__PURE__ */ jsx27("div", {
|
|
975
1404
|
className: "lg:pl-4",
|
|
976
|
-
children: /* @__PURE__ */
|
|
1405
|
+
children: /* @__PURE__ */ jsx27(APICodePanel, {
|
|
977
1406
|
languages,
|
|
978
1407
|
examples,
|
|
979
1408
|
externalLink,
|
|
@@ -985,10 +1414,86 @@ function APISection({
|
|
|
985
1414
|
})
|
|
986
1415
|
});
|
|
987
1416
|
}
|
|
1417
|
+
// src/docskit/api/code-block.tsx
|
|
1418
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
1419
|
+
|
|
1420
|
+
function CodeBlock({
|
|
1421
|
+
code,
|
|
1422
|
+
language = "typescript",
|
|
1423
|
+
showLineNumbers = false,
|
|
1424
|
+
className
|
|
1425
|
+
}) {
|
|
1426
|
+
const flags = `-c${showLineNumbers ? "n" : ""}`;
|
|
1427
|
+
return /* @__PURE__ */ jsx28(ClientDocsKitCode, {
|
|
1428
|
+
codeblock: {
|
|
1429
|
+
value: code,
|
|
1430
|
+
lang: language,
|
|
1431
|
+
meta: flags
|
|
1432
|
+
},
|
|
1433
|
+
className: cn("my-0 border-[var(--openpkg-border-subtle)]", className)
|
|
1434
|
+
});
|
|
1435
|
+
}
|
|
1436
|
+
// src/docskit/api/collapsible-panel.tsx
|
|
1437
|
+
import { ChevronRight } from "lucide-react";
|
|
1438
|
+
import { useId as useId2, useState as useState6 } from "react";
|
|
1439
|
+
import { jsx as jsx29, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1440
|
+
|
|
1441
|
+
function CollapsiblePanel({
|
|
1442
|
+
title,
|
|
1443
|
+
children,
|
|
1444
|
+
defaultExpanded = false,
|
|
1445
|
+
expanded: controlledExpanded,
|
|
1446
|
+
onExpandedChange,
|
|
1447
|
+
className
|
|
1448
|
+
}) {
|
|
1449
|
+
const [internalExpanded, setInternalExpanded] = useState6(defaultExpanded);
|
|
1450
|
+
const isControlled = controlledExpanded !== undefined;
|
|
1451
|
+
const expanded = isControlled ? controlledExpanded : internalExpanded;
|
|
1452
|
+
const contentId = useId2();
|
|
1453
|
+
const toggle = () => {
|
|
1454
|
+
const next = !expanded;
|
|
1455
|
+
if (isControlled) {
|
|
1456
|
+
onExpandedChange?.(next);
|
|
1457
|
+
} else {
|
|
1458
|
+
setInternalExpanded(next);
|
|
1459
|
+
}
|
|
1460
|
+
};
|
|
1461
|
+
return /* @__PURE__ */ jsxs15("div", {
|
|
1462
|
+
className: cn("openpkg-collapsible-panel", className),
|
|
1463
|
+
children: [
|
|
1464
|
+
/* @__PURE__ */ jsxs15("button", {
|
|
1465
|
+
type: "button",
|
|
1466
|
+
onClick: toggle,
|
|
1467
|
+
"aria-expanded": expanded,
|
|
1468
|
+
"aria-controls": contentId,
|
|
1469
|
+
className: cn("openpkg-collapsible-trigger", "flex items-center gap-2.5 w-full", "px-4 py-3", "bg-[var(--openpkg-bg-collapsible)]", "border border-[var(--openpkg-border-subtle)]", "rounded-md", "cursor-pointer", "transition-all duration-150", "hover:bg-[var(--openpkg-bg-tertiary)]", expanded && "rounded-b-none border-b-transparent mb-0", !expanded && "mb-2"),
|
|
1470
|
+
children: [
|
|
1471
|
+
/* @__PURE__ */ jsx29(ChevronRight, {
|
|
1472
|
+
size: 14,
|
|
1473
|
+
className: cn("text-[var(--openpkg-text-muted)]", "transition-transform duration-200", expanded && "rotate-90")
|
|
1474
|
+
}),
|
|
1475
|
+
/* @__PURE__ */ jsx29("span", {
|
|
1476
|
+
className: "text-[13px] font-medium text-[var(--openpkg-text-secondary)]",
|
|
1477
|
+
children: title
|
|
1478
|
+
})
|
|
1479
|
+
]
|
|
1480
|
+
}),
|
|
1481
|
+
/* @__PURE__ */ jsx29("div", {
|
|
1482
|
+
id: contentId,
|
|
1483
|
+
role: "region",
|
|
1484
|
+
className: cn("openpkg-collapsible-content", "grid transition-[grid-template-rows,opacity] duration-200 ease-out", expanded ? "grid-rows-[1fr] opacity-100" : "grid-rows-[0fr] opacity-0"),
|
|
1485
|
+
children: /* @__PURE__ */ jsx29("div", {
|
|
1486
|
+
className: cn("min-h-0 overflow-hidden", "bg-[var(--openpkg-bg-code)]", "border border-[var(--openpkg-border-subtle)]", "border-t-0", "rounded-b-md", "mb-2"),
|
|
1487
|
+
children
|
|
1488
|
+
})
|
|
1489
|
+
})
|
|
1490
|
+
]
|
|
1491
|
+
});
|
|
1492
|
+
}
|
|
988
1493
|
// src/docskit/api/endpoint-badge.tsx
|
|
989
1494
|
import { cva } from "class-variance-authority";
|
|
990
|
-
import * as
|
|
991
|
-
import { jsx as
|
|
1495
|
+
import * as React4 from "react";
|
|
1496
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
992
1497
|
var endpointBadgeVariants = cva("inline-flex items-center justify-center font-mono font-bold uppercase tracking-wide rounded shrink-0", {
|
|
993
1498
|
variants: {
|
|
994
1499
|
method: {
|
|
@@ -1008,8 +1513,8 @@ var endpointBadgeVariants = cva("inline-flex items-center justify-center font-mo
|
|
|
1008
1513
|
size: "md"
|
|
1009
1514
|
}
|
|
1010
1515
|
});
|
|
1011
|
-
var EndpointBadge =
|
|
1012
|
-
return /* @__PURE__ */
|
|
1516
|
+
var EndpointBadge = React4.forwardRef(({ className, method, size, ...props }, ref) => {
|
|
1517
|
+
return /* @__PURE__ */ jsx30("span", {
|
|
1013
1518
|
ref,
|
|
1014
1519
|
className: cn(endpointBadgeVariants({ method, size, className })),
|
|
1015
1520
|
...props,
|
|
@@ -1019,37 +1524,37 @@ var EndpointBadge = React3.forwardRef(({ className, method, size, ...props }, re
|
|
|
1019
1524
|
EndpointBadge.displayName = "EndpointBadge";
|
|
1020
1525
|
// src/docskit/api/endpoint-header.tsx
|
|
1021
1526
|
import { Check as Check2, Copy as Copy2 } from "lucide-react";
|
|
1022
|
-
import * as
|
|
1023
|
-
import { useState as
|
|
1024
|
-
import { jsx as
|
|
1527
|
+
import * as React5 from "react";
|
|
1528
|
+
import { useState as useState7 } from "react";
|
|
1529
|
+
import { jsx as jsx31, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1025
1530
|
|
|
1026
|
-
var EndpointHeader =
|
|
1027
|
-
const [copied, setCopied] =
|
|
1531
|
+
var EndpointHeader = React5.forwardRef(({ className, method, path, copyable = true, ...props }, ref) => {
|
|
1532
|
+
const [copied, setCopied] = useState7(false);
|
|
1028
1533
|
const handleCopy = () => {
|
|
1029
1534
|
navigator.clipboard.writeText(path);
|
|
1030
1535
|
setCopied(true);
|
|
1031
1536
|
setTimeout(() => setCopied(false), 1200);
|
|
1032
1537
|
};
|
|
1033
|
-
return /* @__PURE__ */
|
|
1538
|
+
return /* @__PURE__ */ jsxs16("div", {
|
|
1034
1539
|
ref,
|
|
1035
1540
|
className: cn("group flex items-center gap-3 py-2 px-3 rounded-lg bg-muted/50 border border-border", className),
|
|
1036
1541
|
...props,
|
|
1037
1542
|
children: [
|
|
1038
|
-
/* @__PURE__ */
|
|
1543
|
+
/* @__PURE__ */ jsx31(EndpointBadge, {
|
|
1039
1544
|
method
|
|
1040
1545
|
}),
|
|
1041
|
-
/* @__PURE__ */
|
|
1546
|
+
/* @__PURE__ */ jsx31("code", {
|
|
1042
1547
|
className: "font-mono text-sm text-foreground flex-1",
|
|
1043
1548
|
children: path
|
|
1044
1549
|
}),
|
|
1045
|
-
copyable && /* @__PURE__ */
|
|
1550
|
+
copyable && /* @__PURE__ */ jsx31("button", {
|
|
1046
1551
|
type: "button",
|
|
1047
1552
|
onClick: handleCopy,
|
|
1048
1553
|
className: cn("p-1.5 rounded text-muted-foreground hover:text-foreground", "opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer"),
|
|
1049
1554
|
"aria-label": "Copy path",
|
|
1050
|
-
children: copied ? /* @__PURE__ */
|
|
1555
|
+
children: copied ? /* @__PURE__ */ jsx31(Check2, {
|
|
1051
1556
|
size: 14
|
|
1052
|
-
}) : /* @__PURE__ */
|
|
1557
|
+
}) : /* @__PURE__ */ jsx31(Copy2, {
|
|
1053
1558
|
size: 14
|
|
1054
1559
|
})
|
|
1055
1560
|
})
|
|
@@ -1057,237 +1562,575 @@ var EndpointHeader = React4.forwardRef(({ className, method, path, copyable = tr
|
|
|
1057
1562
|
});
|
|
1058
1563
|
});
|
|
1059
1564
|
EndpointHeader.displayName = "EndpointHeader";
|
|
1060
|
-
// src/docskit/api/
|
|
1061
|
-
import {
|
|
1062
|
-
import { useState as useState5 } from "react";
|
|
1063
|
-
import { jsx as jsx25, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1565
|
+
// src/docskit/api/enum-values-section.tsx
|
|
1566
|
+
import { jsx as jsx32, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
1064
1567
|
|
|
1065
|
-
function
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
depth = 0
|
|
1568
|
+
function EnumValuesSection({
|
|
1569
|
+
values,
|
|
1570
|
+
header = "Possible values",
|
|
1571
|
+
className
|
|
1070
1572
|
}) {
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
const _nestedCount = hasNested ? Object.keys(schema.properties).length : 0;
|
|
1076
|
-
const handleCopy = () => {
|
|
1077
|
-
navigator.clipboard.writeText(name);
|
|
1078
|
-
setCopied(true);
|
|
1079
|
-
setTimeout(() => setCopied(false), 1200);
|
|
1080
|
-
};
|
|
1081
|
-
return /* @__PURE__ */ jsxs14("div", {
|
|
1082
|
-
className: cn("border-t border-border first:border-t-0", depth > 0 && "ml-4"),
|
|
1573
|
+
if (values.length === 0)
|
|
1574
|
+
return null;
|
|
1575
|
+
return /* @__PURE__ */ jsxs17("div", {
|
|
1576
|
+
className: cn("openpkg-enum-section", "mt-3", className),
|
|
1083
1577
|
children: [
|
|
1084
|
-
/* @__PURE__ */
|
|
1085
|
-
className: "
|
|
1086
|
-
children:
|
|
1087
|
-
|
|
1578
|
+
/* @__PURE__ */ jsx32("div", {
|
|
1579
|
+
className: cn("openpkg-enum-header", "text-[11px] font-medium", "text-[var(--openpkg-text-muted)]", "mb-2.5 pb-2", "border-b border-[var(--openpkg-border-subtle)]"),
|
|
1580
|
+
children: header
|
|
1581
|
+
}),
|
|
1582
|
+
/* @__PURE__ */ jsx32("div", {
|
|
1583
|
+
className: "openpkg-enum-values flex flex-col gap-0.5",
|
|
1584
|
+
children: values.map((item) => /* @__PURE__ */ jsxs17("div", {
|
|
1585
|
+
className: cn("openpkg-enum-value", "py-2.5 px-3", "bg-[var(--openpkg-bg-secondary)]", "rounded"),
|
|
1088
1586
|
children: [
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
className: "mt-0.5 p-0.5 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",
|
|
1093
|
-
"aria-label": expanded ? "Collapse" : "Expand",
|
|
1094
|
-
children: /* @__PURE__ */ jsx25(ChevronRight, {
|
|
1095
|
-
size: 14,
|
|
1096
|
-
className: cn("transition-transform duration-200", expanded && "rotate-90")
|
|
1097
|
-
})
|
|
1098
|
-
}) : /* @__PURE__ */ jsx25("div", {
|
|
1099
|
-
className: "w-5"
|
|
1587
|
+
/* @__PURE__ */ jsx32("span", {
|
|
1588
|
+
className: cn("openpkg-enum-value-name", "font-mono text-xs font-medium", "text-[var(--openpkg-syn-string)]", "bg-[var(--openpkg-bg-badge)]", "px-1.5 py-0.5 rounded", "inline-block mb-1"),
|
|
1589
|
+
children: item.value
|
|
1100
1590
|
}),
|
|
1101
|
-
/* @__PURE__ */
|
|
1102
|
-
className: "
|
|
1103
|
-
children:
|
|
1104
|
-
/* @__PURE__ */ jsxs14("div", {
|
|
1105
|
-
className: "flex items-center gap-2 flex-wrap",
|
|
1106
|
-
children: [
|
|
1107
|
-
/* @__PURE__ */ jsxs14("span", {
|
|
1108
|
-
className: "font-mono text-sm font-medium text-foreground",
|
|
1109
|
-
children: [
|
|
1110
|
-
name,
|
|
1111
|
-
!required && /* @__PURE__ */ jsx25("span", {
|
|
1112
|
-
className: "text-muted-foreground",
|
|
1113
|
-
children: "?"
|
|
1114
|
-
})
|
|
1115
|
-
]
|
|
1116
|
-
}),
|
|
1117
|
-
/* @__PURE__ */ jsx25("span", {
|
|
1118
|
-
className: "font-mono text-xs text-muted-foreground",
|
|
1119
|
-
children: type
|
|
1120
|
-
}),
|
|
1121
|
-
hasNested && /* @__PURE__ */ jsx25("button", {
|
|
1122
|
-
type: "button",
|
|
1123
|
-
onClick: () => setExpanded(!expanded),
|
|
1124
|
-
className: "text-xs text-primary hover:underline cursor-pointer",
|
|
1125
|
-
children: "Show child parameters"
|
|
1126
|
-
}),
|
|
1127
|
-
/* @__PURE__ */ jsx25("button", {
|
|
1128
|
-
type: "button",
|
|
1129
|
-
onClick: handleCopy,
|
|
1130
|
-
className: "p-1 rounded text-muted-foreground hover:text-foreground opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",
|
|
1131
|
-
"aria-label": "Copy name",
|
|
1132
|
-
children: copied ? /* @__PURE__ */ jsx25(Check3, {
|
|
1133
|
-
size: 12
|
|
1134
|
-
}) : /* @__PURE__ */ jsx25(Copy3, {
|
|
1135
|
-
size: 12
|
|
1136
|
-
})
|
|
1137
|
-
})
|
|
1138
|
-
]
|
|
1139
|
-
}),
|
|
1140
|
-
schema.description && /* @__PURE__ */ jsx25("p", {
|
|
1141
|
-
className: "text-sm text-muted-foreground mt-1",
|
|
1142
|
-
children: schema.description
|
|
1143
|
-
})
|
|
1144
|
-
]
|
|
1591
|
+
item.description && /* @__PURE__ */ jsx32("p", {
|
|
1592
|
+
className: cn("openpkg-enum-value-description", "text-xs text-[var(--openpkg-text-secondary)]", "leading-relaxed", "[&_code]:font-mono [&_code]:text-[11px] [&_code]:bg-[var(--openpkg-bg-badge)] [&_code]:px-1 [&_code]:py-0.5 [&_code]:rounded"),
|
|
1593
|
+
children: item.description
|
|
1145
1594
|
})
|
|
1146
1595
|
]
|
|
1596
|
+
}, item.value))
|
|
1597
|
+
})
|
|
1598
|
+
]
|
|
1599
|
+
});
|
|
1600
|
+
}
|
|
1601
|
+
// src/docskit/api/example-chips.tsx
|
|
1602
|
+
import { jsx as jsx33 } from "react/jsx-runtime";
|
|
1603
|
+
|
|
1604
|
+
function ExampleChips({
|
|
1605
|
+
examples,
|
|
1606
|
+
activeId,
|
|
1607
|
+
onSelect,
|
|
1608
|
+
className
|
|
1609
|
+
}) {
|
|
1610
|
+
return /* @__PURE__ */ jsx33("div", {
|
|
1611
|
+
className: cn("openpkg-example-chips", "flex flex-wrap gap-2 mb-5", className),
|
|
1612
|
+
children: examples.map((example) => {
|
|
1613
|
+
const isActive = example.id === activeId;
|
|
1614
|
+
return /* @__PURE__ */ jsx33("button", {
|
|
1615
|
+
type: "button",
|
|
1616
|
+
onClick: () => onSelect(example.id),
|
|
1617
|
+
className: cn("openpkg-example-chip", "text-xs font-medium", "px-3 py-1.5", "border rounded-md", "cursor-pointer", "transition-all duration-150", isActive ? [
|
|
1618
|
+
"border-[var(--openpkg-border-chip-active)]",
|
|
1619
|
+
"text-[var(--openpkg-text-primary)]",
|
|
1620
|
+
"bg-[var(--openpkg-bg-tertiary)]"
|
|
1621
|
+
] : [
|
|
1622
|
+
"border-[var(--openpkg-border-chip)]",
|
|
1623
|
+
"text-[var(--openpkg-text-secondary)]",
|
|
1624
|
+
"bg-transparent",
|
|
1625
|
+
"hover:border-[var(--openpkg-text-muted)]",
|
|
1626
|
+
"hover:text-[var(--openpkg-text-primary)]"
|
|
1627
|
+
]),
|
|
1628
|
+
"aria-pressed": isActive,
|
|
1629
|
+
children: example.label
|
|
1630
|
+
}, example.id);
|
|
1631
|
+
})
|
|
1632
|
+
});
|
|
1633
|
+
}
|
|
1634
|
+
// src/docskit/api/example-section.tsx
|
|
1635
|
+
import { useEffect as useEffect4, useRef as useRef3, useState as useState9 } from "react";
|
|
1636
|
+
|
|
1637
|
+
// src/docskit/hooks/use-sync-scroll.tsx
|
|
1638
|
+
import {
|
|
1639
|
+
createContext as createContext2,
|
|
1640
|
+
useCallback,
|
|
1641
|
+
useContext as useContext2,
|
|
1642
|
+
useEffect as useEffect3,
|
|
1643
|
+
useMemo,
|
|
1644
|
+
useRef as useRef2,
|
|
1645
|
+
useState as useState8
|
|
1646
|
+
} from "react";
|
|
1647
|
+
import { jsx as jsx34 } from "react/jsx-runtime";
|
|
1648
|
+
|
|
1649
|
+
var SyncScrollContext = createContext2(null);
|
|
1650
|
+
function SyncScrollProvider({
|
|
1651
|
+
children,
|
|
1652
|
+
rootMargin = "-20% 0px -60% 0px",
|
|
1653
|
+
scrollBehavior = "smooth"
|
|
1654
|
+
}) {
|
|
1655
|
+
const [activeSection, setActiveSection] = useState8(null);
|
|
1656
|
+
const sectionsRef = useRef2(new Map);
|
|
1657
|
+
const rightColumnRef = useRef2(null);
|
|
1658
|
+
const isScrollingRef = useRef2(false);
|
|
1659
|
+
const registerSection = useCallback((id, ref) => {
|
|
1660
|
+
sectionsRef.current.set(id, ref);
|
|
1661
|
+
}, []);
|
|
1662
|
+
const unregisterSection = useCallback((id) => {
|
|
1663
|
+
sectionsRef.current.delete(id);
|
|
1664
|
+
}, []);
|
|
1665
|
+
const registerRightColumn = useCallback((ref) => {
|
|
1666
|
+
rightColumnRef.current = ref;
|
|
1667
|
+
}, []);
|
|
1668
|
+
const scrollToSection = useCallback((id) => {
|
|
1669
|
+
const rightColumn = rightColumnRef.current?.current;
|
|
1670
|
+
if (!rightColumn)
|
|
1671
|
+
return;
|
|
1672
|
+
const targetExample = rightColumn.querySelector(`[data-section="${id}"]`);
|
|
1673
|
+
if (targetExample instanceof HTMLElement) {
|
|
1674
|
+
const targetTop = targetExample.offsetTop - 48;
|
|
1675
|
+
rightColumn.scrollTo({ top: targetTop, behavior: scrollBehavior });
|
|
1676
|
+
}
|
|
1677
|
+
}, [scrollBehavior]);
|
|
1678
|
+
useEffect3(() => {
|
|
1679
|
+
if (typeof window === "undefined")
|
|
1680
|
+
return;
|
|
1681
|
+
const handleIntersect = (entries) => {
|
|
1682
|
+
if (isScrollingRef.current)
|
|
1683
|
+
return;
|
|
1684
|
+
for (const entry of entries) {
|
|
1685
|
+
if (entry.isIntersecting) {
|
|
1686
|
+
const sectionId = entry.target.getAttribute("data-section");
|
|
1687
|
+
if (sectionId) {
|
|
1688
|
+
setActiveSection(sectionId);
|
|
1689
|
+
scrollToSection(sectionId);
|
|
1690
|
+
}
|
|
1691
|
+
break;
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
};
|
|
1695
|
+
const observer = new IntersectionObserver(handleIntersect, {
|
|
1696
|
+
rootMargin,
|
|
1697
|
+
threshold: 0
|
|
1698
|
+
});
|
|
1699
|
+
for (const [_id, ref] of sectionsRef.current) {
|
|
1700
|
+
if (ref.current) {
|
|
1701
|
+
observer.observe(ref.current);
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
return () => {
|
|
1705
|
+
observer.disconnect();
|
|
1706
|
+
};
|
|
1707
|
+
}, [rootMargin, scrollToSection]);
|
|
1708
|
+
const value = useMemo(() => ({
|
|
1709
|
+
activeSection,
|
|
1710
|
+
registerSection,
|
|
1711
|
+
unregisterSection,
|
|
1712
|
+
scrollToSection,
|
|
1713
|
+
registerRightColumn
|
|
1714
|
+
}), [activeSection, registerSection, unregisterSection, scrollToSection, registerRightColumn]);
|
|
1715
|
+
return /* @__PURE__ */ jsx34(SyncScrollContext.Provider, {
|
|
1716
|
+
value,
|
|
1717
|
+
children
|
|
1718
|
+
});
|
|
1719
|
+
}
|
|
1720
|
+
function useSyncScroll() {
|
|
1721
|
+
const context = useContext2(SyncScrollContext);
|
|
1722
|
+
if (!context) {
|
|
1723
|
+
throw new Error("useSyncScroll must be used within SyncScrollProvider");
|
|
1724
|
+
}
|
|
1725
|
+
return context;
|
|
1726
|
+
}
|
|
1727
|
+
function useSyncSection(id) {
|
|
1728
|
+
const { registerSection, unregisterSection } = useSyncScroll();
|
|
1729
|
+
const ref = useRef2(null);
|
|
1730
|
+
useEffect3(() => {
|
|
1731
|
+
registerSection(id, ref);
|
|
1732
|
+
return () => unregisterSection(id);
|
|
1733
|
+
}, [id, registerSection, unregisterSection]);
|
|
1734
|
+
return ref;
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
// src/docskit/api/example-section.tsx
|
|
1738
|
+
import { jsx as jsx35, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
1739
|
+
|
|
1740
|
+
function ExampleSection({
|
|
1741
|
+
id,
|
|
1742
|
+
examples,
|
|
1743
|
+
dataSource,
|
|
1744
|
+
response,
|
|
1745
|
+
notes,
|
|
1746
|
+
className
|
|
1747
|
+
}) {
|
|
1748
|
+
const [activeExampleId, setActiveExampleId] = useState9(examples[0]?.id ?? "");
|
|
1749
|
+
const ref = useRef3(null);
|
|
1750
|
+
const syncScroll = useSyncScrollSafe();
|
|
1751
|
+
const activeExample = examples.find((e) => e.id === activeExampleId) ?? examples[0];
|
|
1752
|
+
const isActive = syncScroll?.activeSection === id;
|
|
1753
|
+
useEffect4(() => {
|
|
1754
|
+
if (ref.current) {
|
|
1755
|
+
ref.current.setAttribute("data-section", id);
|
|
1756
|
+
}
|
|
1757
|
+
}, [id]);
|
|
1758
|
+
return /* @__PURE__ */ jsxs18("div", {
|
|
1759
|
+
ref,
|
|
1760
|
+
"data-section": id,
|
|
1761
|
+
className: cn("openpkg-example-section", "mb-12 last:mb-0", "transition-opacity duration-300", isActive ? "opacity-100" : "opacity-40", className),
|
|
1762
|
+
children: [
|
|
1763
|
+
examples.length > 1 && /* @__PURE__ */ jsx35(ExampleChips, {
|
|
1764
|
+
examples: examples.map((e) => ({ id: e.id, label: e.label })),
|
|
1765
|
+
activeId: activeExampleId,
|
|
1766
|
+
onSelect: setActiveExampleId
|
|
1767
|
+
}),
|
|
1768
|
+
activeExample && /* @__PURE__ */ jsx35(CodeBlock, {
|
|
1769
|
+
code: activeExample.code,
|
|
1770
|
+
language: activeExample.language ?? "typescript",
|
|
1771
|
+
showLineNumbers: true
|
|
1772
|
+
}),
|
|
1773
|
+
dataSource && /* @__PURE__ */ jsx35(CollapsiblePanel, {
|
|
1774
|
+
title: "Data source",
|
|
1775
|
+
children: /* @__PURE__ */ jsx35("div", {
|
|
1776
|
+
className: "p-4",
|
|
1777
|
+
children: /* @__PURE__ */ jsx35(CodeBlock, {
|
|
1778
|
+
code: dataSource,
|
|
1779
|
+
language: "sql"
|
|
1780
|
+
})
|
|
1781
|
+
})
|
|
1782
|
+
}),
|
|
1783
|
+
response && /* @__PURE__ */ jsx35(CollapsiblePanel, {
|
|
1784
|
+
title: "Response",
|
|
1785
|
+
children: /* @__PURE__ */ jsx35("div", {
|
|
1786
|
+
className: "p-4",
|
|
1787
|
+
children: /* @__PURE__ */ jsx35(CodeBlock, {
|
|
1788
|
+
code: response,
|
|
1789
|
+
language: "json"
|
|
1790
|
+
})
|
|
1147
1791
|
})
|
|
1148
1792
|
}),
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
children:
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
}
|
|
1793
|
+
notes && /* @__PURE__ */ jsx35(CollapsiblePanel, {
|
|
1794
|
+
title: "Notes",
|
|
1795
|
+
children: /* @__PURE__ */ jsx35("div", {
|
|
1796
|
+
className: cn("openpkg-panel-note", "p-4", "text-[13px] text-[var(--openpkg-text-secondary)]", "leading-relaxed", "[&_code]:font-mono [&_code]:text-xs [&_code]:bg-[var(--openpkg-bg-badge)] [&_code]:px-1.5 [&_code]:py-0.5 [&_code]:rounded"),
|
|
1797
|
+
children: typeof notes === "string" ? /* @__PURE__ */ jsx35("p", {
|
|
1798
|
+
children: notes
|
|
1799
|
+
}) : notes
|
|
1800
|
+
})
|
|
1157
1801
|
})
|
|
1158
1802
|
]
|
|
1159
1803
|
});
|
|
1160
1804
|
}
|
|
1805
|
+
function useSyncScrollSafe() {
|
|
1806
|
+
try {
|
|
1807
|
+
return useSyncScroll();
|
|
1808
|
+
} catch {
|
|
1809
|
+
return null;
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
// src/docskit/api/expandable-parameter.tsx
|
|
1813
|
+
import { formatSchema } from "@openpkg-ts/sdk/browser";
|
|
1814
|
+
import { useState as useState10 } from "react";
|
|
1815
|
+
|
|
1816
|
+
// src/docskit/api/parameter-item.tsx
|
|
1817
|
+
import { Link } from "lucide-react";
|
|
1818
|
+
import { jsx as jsx36, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
1819
|
+
|
|
1161
1820
|
function APIParameterItem({
|
|
1162
1821
|
name,
|
|
1822
|
+
parentPath,
|
|
1163
1823
|
type,
|
|
1164
|
-
required
|
|
1824
|
+
required,
|
|
1825
|
+
optional,
|
|
1826
|
+
expandable: expandable2,
|
|
1165
1827
|
description,
|
|
1166
1828
|
children,
|
|
1167
|
-
|
|
1829
|
+
anchorId,
|
|
1830
|
+
showAnchor = false,
|
|
1168
1831
|
className
|
|
1169
1832
|
}) {
|
|
1170
|
-
const
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
navigator.clipboard.writeText(name);
|
|
1176
|
-
setCopied(true);
|
|
1177
|
-
setTimeout(() => setCopied(false), 1200);
|
|
1833
|
+
const handleAnchorClick = () => {
|
|
1834
|
+
if (anchorId && typeof window !== "undefined") {
|
|
1835
|
+
window.location.hash = anchorId;
|
|
1836
|
+
navigator.clipboard?.writeText(window.location.href);
|
|
1837
|
+
}
|
|
1178
1838
|
};
|
|
1179
|
-
return /* @__PURE__ */
|
|
1180
|
-
|
|
1839
|
+
return /* @__PURE__ */ jsxs19("div", {
|
|
1840
|
+
id: anchorId,
|
|
1841
|
+
className: cn("openpkg-param", "py-5 border-b border-[var(--openpkg-border-subtle)]", "last:border-b-0", className),
|
|
1181
1842
|
children: [
|
|
1182
|
-
/* @__PURE__ */
|
|
1183
|
-
className: "
|
|
1184
|
-
children:
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
children: /* @__PURE__ */ jsx25(ChevronRight, {
|
|
1193
|
-
size: 14,
|
|
1194
|
-
className: cn("transition-transform duration-200", expanded && "rotate-90")
|
|
1195
|
-
})
|
|
1196
|
-
}) : /* @__PURE__ */ jsx25("div", {
|
|
1197
|
-
className: "w-5"
|
|
1198
|
-
}),
|
|
1199
|
-
/* @__PURE__ */ jsxs14("div", {
|
|
1200
|
-
className: "flex-1 min-w-0",
|
|
1201
|
-
children: [
|
|
1202
|
-
/* @__PURE__ */ jsxs14("div", {
|
|
1203
|
-
className: "flex items-center gap-2 flex-wrap",
|
|
1204
|
-
children: [
|
|
1205
|
-
/* @__PURE__ */ jsx25("span", {
|
|
1206
|
-
className: "font-mono text-sm font-medium text-foreground",
|
|
1207
|
-
children: name
|
|
1208
|
-
}),
|
|
1209
|
-
required && /* @__PURE__ */ jsx25("span", {
|
|
1210
|
-
className: "text-[10px] font-semibold px-1.5 py-0.5 rounded border border-border bg-muted text-muted-foreground uppercase tracking-wide",
|
|
1211
|
-
children: "Required"
|
|
1212
|
-
}),
|
|
1213
|
-
/* @__PURE__ */ jsx25("span", {
|
|
1214
|
-
className: "font-mono text-xs text-muted-foreground",
|
|
1215
|
-
children: type
|
|
1216
|
-
}),
|
|
1217
|
-
hasNested && /* @__PURE__ */ jsx25("button", {
|
|
1218
|
-
type: "button",
|
|
1219
|
-
onClick: () => setExpanded(!expanded),
|
|
1220
|
-
className: "text-xs text-primary hover:underline cursor-pointer",
|
|
1221
|
-
children: "Show child parameters"
|
|
1222
|
-
}),
|
|
1223
|
-
/* @__PURE__ */ jsx25("button", {
|
|
1224
|
-
type: "button",
|
|
1225
|
-
onClick: handleCopy,
|
|
1226
|
-
className: "p-1 rounded text-muted-foreground hover:text-foreground opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",
|
|
1227
|
-
"aria-label": "Copy name",
|
|
1228
|
-
children: copied ? /* @__PURE__ */ jsx25(Check3, {
|
|
1229
|
-
size: 12
|
|
1230
|
-
}) : /* @__PURE__ */ jsx25(Copy3, {
|
|
1231
|
-
size: 12
|
|
1232
|
-
})
|
|
1233
|
-
})
|
|
1234
|
-
]
|
|
1235
|
-
}),
|
|
1236
|
-
description && /* @__PURE__ */ jsx25("p", {
|
|
1237
|
-
className: "text-sm text-muted-foreground mt-1",
|
|
1238
|
-
children: description
|
|
1239
|
-
})
|
|
1240
|
-
]
|
|
1843
|
+
/* @__PURE__ */ jsxs19("div", {
|
|
1844
|
+
className: "openpkg-param-header flex items-center gap-2.5 mb-2 flex-wrap",
|
|
1845
|
+
children: [
|
|
1846
|
+
showAnchor && /* @__PURE__ */ jsx36("button", {
|
|
1847
|
+
type: "button",
|
|
1848
|
+
onClick: handleAnchorClick,
|
|
1849
|
+
className: cn("openpkg-anchor-link", "flex items-center justify-center w-4 h-4", "opacity-0 group-hover:opacity-100 hover:opacity-100", "text-[var(--openpkg-text-muted)]", "hover:text-[var(--openpkg-accent-blue)]", "cursor-pointer transition-opacity"),
|
|
1850
|
+
"aria-label": "Copy link",
|
|
1851
|
+
children: /* @__PURE__ */ jsx36(Link, {
|
|
1852
|
+
size: 14
|
|
1241
1853
|
})
|
|
1242
|
-
|
|
1243
|
-
|
|
1854
|
+
}),
|
|
1855
|
+
/* @__PURE__ */ jsxs19("span", {
|
|
1856
|
+
className: "openpkg-param-name font-mono text-sm font-semibold",
|
|
1857
|
+
children: [
|
|
1858
|
+
parentPath && /* @__PURE__ */ jsx36("span", {
|
|
1859
|
+
className: "text-[var(--openpkg-text-muted)]",
|
|
1860
|
+
children: parentPath
|
|
1861
|
+
}),
|
|
1862
|
+
/* @__PURE__ */ jsx36("span", {
|
|
1863
|
+
className: "text-[var(--openpkg-text-primary)]",
|
|
1864
|
+
children: name
|
|
1865
|
+
})
|
|
1866
|
+
]
|
|
1867
|
+
}),
|
|
1868
|
+
required && /* @__PURE__ */ jsx36("span", {
|
|
1869
|
+
className: cn("openpkg-param-badge", "text-[11px] font-medium uppercase tracking-wide", "px-2 py-0.5 rounded", "bg-[var(--openpkg-bg-badge)]", "text-[var(--openpkg-text-muted)]"),
|
|
1870
|
+
children: "Required"
|
|
1871
|
+
}),
|
|
1872
|
+
optional && /* @__PURE__ */ jsx36("span", {
|
|
1873
|
+
className: cn("openpkg-param-badge", "text-[11px] font-medium uppercase tracking-wide", "px-2 py-0.5 rounded", "bg-[var(--openpkg-bg-badge)]", "text-[var(--openpkg-text-muted)]"),
|
|
1874
|
+
children: "Optional"
|
|
1875
|
+
}),
|
|
1876
|
+
expandable2 && /* @__PURE__ */ jsx36("span", {
|
|
1877
|
+
className: cn("openpkg-badge-expandable", "text-[10px] font-medium", "px-2 py-0.5 rounded", "text-[var(--openpkg-accent-purple)]", "bg-[color-mix(in_srgb,var(--openpkg-accent-purple)_12%,transparent)]"),
|
|
1878
|
+
children: "Expandable"
|
|
1879
|
+
}),
|
|
1880
|
+
/* @__PURE__ */ jsx36("span", {
|
|
1881
|
+
className: "openpkg-param-type text-[13px] text-[var(--openpkg-text-muted)]",
|
|
1882
|
+
children: type
|
|
1883
|
+
})
|
|
1884
|
+
]
|
|
1244
1885
|
}),
|
|
1245
|
-
|
|
1246
|
-
className: "
|
|
1247
|
-
children:
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
required: children.required?.includes(propName),
|
|
1251
|
-
depth: depth + 1
|
|
1252
|
-
}, propName))
|
|
1253
|
-
})
|
|
1886
|
+
description && /* @__PURE__ */ jsx36("p", {
|
|
1887
|
+
className: cn("openpkg-param-description", "text-sm text-[var(--openpkg-text-secondary)]", "leading-relaxed", "[&_code]:font-mono [&_code]:text-[13px] [&_code]:bg-[var(--openpkg-bg-badge)] [&_code]:px-1.5 [&_code]:py-0.5 [&_code]:rounded"),
|
|
1888
|
+
children: description
|
|
1889
|
+
}),
|
|
1890
|
+
children
|
|
1254
1891
|
]
|
|
1255
1892
|
});
|
|
1256
1893
|
}
|
|
1257
|
-
// src/docskit/api/parameter-list.tsx
|
|
1258
|
-
import { ChevronDown as ChevronDown2 } from "lucide-react";
|
|
1259
|
-
import * as React5 from "react";
|
|
1260
|
-
import { useState as useState6 } from "react";
|
|
1261
|
-
import { jsx as jsx26, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1262
1894
|
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1895
|
+
// src/docskit/api/nested-parameter-container.tsx
|
|
1896
|
+
import { jsx as jsx37 } from "react/jsx-runtime";
|
|
1897
|
+
|
|
1898
|
+
function NestedParameterContainer({
|
|
1266
1899
|
children,
|
|
1900
|
+
level = 0,
|
|
1267
1901
|
className
|
|
1268
1902
|
}) {
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1903
|
+
return /* @__PURE__ */ jsx37("div", {
|
|
1904
|
+
className: cn("openpkg-nested-container", "border border-t-0", level === 0 ? "border-[var(--openpkg-border-medium)]" : "border-[var(--openpkg-border-subtle)]", "rounded-b-lg", "px-5", "mb-2", "[&>.openpkg-param]:py-5", "[&>.openpkg-param]:border-b", "[&>.openpkg-param]:border-[var(--openpkg-border-subtle)]", "[&>.openpkg-param:last-child]:border-b-0", className),
|
|
1905
|
+
"data-level": level,
|
|
1906
|
+
children
|
|
1907
|
+
});
|
|
1908
|
+
}
|
|
1909
|
+
|
|
1910
|
+
// src/docskit/api/nested-parameter-toggle.tsx
|
|
1911
|
+
import { Plus } from "lucide-react";
|
|
1912
|
+
import { jsx as jsx38, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
1913
|
+
|
|
1914
|
+
function NestedParameterToggle({
|
|
1915
|
+
expanded,
|
|
1916
|
+
onToggle,
|
|
1917
|
+
count,
|
|
1918
|
+
className
|
|
1919
|
+
}) {
|
|
1920
|
+
return /* @__PURE__ */ jsxs20("button", {
|
|
1921
|
+
type: "button",
|
|
1922
|
+
onClick: onToggle,
|
|
1923
|
+
className: cn("openpkg-nested-toggle", "inline-flex items-center gap-2", "font-sans text-[13px] font-medium", "text-[var(--openpkg-text-secondary)]", "bg-transparent", "border border-[var(--openpkg-border-medium)]", "rounded-lg", "px-4 py-2.5", "mt-3", "cursor-pointer", "transition-all duration-150", "hover:border-[var(--openpkg-text-muted)]", "hover:text-[var(--openpkg-text-primary)]", expanded && "rounded-b-none border-b-transparent mb-0", className),
|
|
1924
|
+
"aria-expanded": expanded,
|
|
1276
1925
|
children: [
|
|
1277
|
-
|
|
1926
|
+
/* @__PURE__ */ jsx38(Plus, {
|
|
1927
|
+
size: 12,
|
|
1928
|
+
className: cn("transition-transform duration-200", expanded && "rotate-45")
|
|
1929
|
+
}),
|
|
1930
|
+
/* @__PURE__ */ jsxs20("span", {
|
|
1931
|
+
children: [
|
|
1932
|
+
expanded ? "Hide" : "Show",
|
|
1933
|
+
" child parameters",
|
|
1934
|
+
count !== undefined && ` (${count})`
|
|
1935
|
+
]
|
|
1936
|
+
})
|
|
1937
|
+
]
|
|
1938
|
+
});
|
|
1939
|
+
}
|
|
1940
|
+
|
|
1941
|
+
// src/docskit/api/expandable-parameter.tsx
|
|
1942
|
+
import { jsx as jsx39, jsxs as jsxs21, Fragment as Fragment3 } from "react/jsx-runtime";
|
|
1943
|
+
|
|
1944
|
+
function ExpandableParameter({
|
|
1945
|
+
parameter,
|
|
1946
|
+
parentPath,
|
|
1947
|
+
defaultExpanded = false,
|
|
1948
|
+
expanded: controlledExpanded,
|
|
1949
|
+
onExpandedChange,
|
|
1950
|
+
level = 0,
|
|
1951
|
+
className
|
|
1952
|
+
}) {
|
|
1953
|
+
const [internalExpanded, setInternalExpanded] = useState10(defaultExpanded);
|
|
1954
|
+
const isControlled = controlledExpanded !== undefined;
|
|
1955
|
+
const expanded = isControlled ? controlledExpanded : internalExpanded;
|
|
1956
|
+
const handleToggle = () => {
|
|
1957
|
+
const newValue = !expanded;
|
|
1958
|
+
if (isControlled) {
|
|
1959
|
+
onExpandedChange?.(newValue);
|
|
1960
|
+
} else {
|
|
1961
|
+
setInternalExpanded(newValue);
|
|
1962
|
+
}
|
|
1963
|
+
};
|
|
1964
|
+
const { nestedParams, enumValues, hasChildren } = extractSchemaInfo(parameter.schema);
|
|
1965
|
+
const type = formatSchema(parameter.schema);
|
|
1966
|
+
const isRequired = parameter.required !== false;
|
|
1967
|
+
return /* @__PURE__ */ jsx39("div", {
|
|
1968
|
+
className: cn("openpkg-expandable-param", className),
|
|
1969
|
+
children: /* @__PURE__ */ jsxs21(APIParameterItem, {
|
|
1970
|
+
name: parameter.name,
|
|
1971
|
+
parentPath,
|
|
1972
|
+
type: hasChildren ? "object" : type,
|
|
1973
|
+
required: isRequired,
|
|
1974
|
+
expandable: hasChildren,
|
|
1975
|
+
description: parameter.description,
|
|
1976
|
+
anchorId: parentPath ? `${parentPath}${parameter.name}` : parameter.name,
|
|
1977
|
+
showAnchor: level > 0,
|
|
1978
|
+
children: [
|
|
1979
|
+
enumValues.length > 0 && !nestedParams.length && /* @__PURE__ */ jsx39(EnumValuesSection, {
|
|
1980
|
+
values: enumValues
|
|
1981
|
+
}),
|
|
1982
|
+
nestedParams.length > 0 && /* @__PURE__ */ jsxs21(Fragment3, {
|
|
1983
|
+
children: [
|
|
1984
|
+
/* @__PURE__ */ jsx39(NestedParameterToggle, {
|
|
1985
|
+
expanded,
|
|
1986
|
+
onToggle: handleToggle,
|
|
1987
|
+
count: nestedParams.length
|
|
1988
|
+
}),
|
|
1989
|
+
expanded && /* @__PURE__ */ jsx39(NestedParameterContainer, {
|
|
1990
|
+
level,
|
|
1991
|
+
children: nestedParams.map((nested) => /* @__PURE__ */ jsx39(ExpandableParameter, {
|
|
1992
|
+
parameter: nested,
|
|
1993
|
+
parentPath: `${parameter.name}.`,
|
|
1994
|
+
level: level + 1
|
|
1995
|
+
}, nested.name))
|
|
1996
|
+
})
|
|
1997
|
+
]
|
|
1998
|
+
})
|
|
1999
|
+
]
|
|
2000
|
+
})
|
|
2001
|
+
});
|
|
2002
|
+
}
|
|
2003
|
+
function extractSchemaInfo(schema) {
|
|
2004
|
+
const result = {
|
|
2005
|
+
nestedParams: [],
|
|
2006
|
+
enumValues: [],
|
|
2007
|
+
hasChildren: false
|
|
2008
|
+
};
|
|
2009
|
+
if (!schema || typeof schema !== "object")
|
|
2010
|
+
return result;
|
|
2011
|
+
const s = schema;
|
|
2012
|
+
if (s.type === "object" && s.properties && typeof s.properties === "object") {
|
|
2013
|
+
const props = s.properties;
|
|
2014
|
+
const required = Array.isArray(s.required) ? s.required : [];
|
|
2015
|
+
for (const [name, propSchema] of Object.entries(props)) {
|
|
2016
|
+
result.nestedParams.push({
|
|
2017
|
+
name,
|
|
2018
|
+
schema: propSchema,
|
|
2019
|
+
required: required.includes(name),
|
|
2020
|
+
description: propSchema?.description
|
|
2021
|
+
});
|
|
2022
|
+
}
|
|
2023
|
+
}
|
|
2024
|
+
if (Array.isArray(s.enum)) {
|
|
2025
|
+
result.enumValues = s.enum.map((value) => ({
|
|
2026
|
+
value: String(value),
|
|
2027
|
+
description: undefined
|
|
2028
|
+
}));
|
|
2029
|
+
}
|
|
2030
|
+
result.hasChildren = result.nestedParams.length > 0 || result.enumValues.length > 0;
|
|
2031
|
+
return result;
|
|
2032
|
+
}
|
|
2033
|
+
// src/docskit/api/method-section.tsx
|
|
2034
|
+
import { useEffect as useEffect5, useRef as useRef4 } from "react";
|
|
2035
|
+
import { jsx as jsx40, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
2036
|
+
|
|
2037
|
+
function MethodSection({
|
|
2038
|
+
id,
|
|
2039
|
+
title,
|
|
2040
|
+
signature,
|
|
2041
|
+
description,
|
|
2042
|
+
notes,
|
|
2043
|
+
children,
|
|
2044
|
+
className
|
|
2045
|
+
}) {
|
|
2046
|
+
const ref = useRef4(null);
|
|
2047
|
+
const syncScroll = useSyncScrollSafe2();
|
|
2048
|
+
useEffect5(() => {
|
|
2049
|
+
if (syncScroll && ref.current) {
|
|
2050
|
+
syncScroll.registerSection(id, ref);
|
|
2051
|
+
return () => syncScroll.unregisterSection(id);
|
|
2052
|
+
}
|
|
2053
|
+
}, [id, syncScroll]);
|
|
2054
|
+
return /* @__PURE__ */ jsxs22("section", {
|
|
2055
|
+
ref,
|
|
2056
|
+
id,
|
|
2057
|
+
"data-section": id,
|
|
2058
|
+
className: cn("openpkg-method-section", "mb-20 last:mb-0", className),
|
|
2059
|
+
children: [
|
|
2060
|
+
/* @__PURE__ */ jsx40("h2", {
|
|
2061
|
+
className: cn("text-2xl font-semibold tracking-tight", "text-[var(--openpkg-text-primary)]", "mb-4"),
|
|
2062
|
+
children: title
|
|
2063
|
+
}),
|
|
2064
|
+
signature && /* @__PURE__ */ jsx40("code", {
|
|
2065
|
+
className: cn("block font-mono text-sm", "text-[var(--openpkg-text-muted)]", "mb-6"),
|
|
2066
|
+
children: signature
|
|
2067
|
+
}),
|
|
2068
|
+
description && /* @__PURE__ */ jsx40("div", {
|
|
2069
|
+
className: cn("openpkg-method-description", "text-[15px] leading-relaxed", "text-[var(--openpkg-text-secondary)]", "mb-6", "[&_a]:text-[var(--openpkg-accent-link)] [&_a]:no-underline [&_a]:font-medium hover:[&_a]:underline", "[&_code]:bg-[var(--openpkg-bg-badge)] [&_code]:px-1.5 [&_code]:py-0.5 [&_code]:rounded [&_code]:font-mono [&_code]:text-[13px]"),
|
|
2070
|
+
children: typeof description === "string" ? /* @__PURE__ */ jsx40("p", {
|
|
2071
|
+
children: description
|
|
2072
|
+
}) : description
|
|
2073
|
+
}),
|
|
2074
|
+
notes && notes.length > 0 && /* @__PURE__ */ jsx40("ul", {
|
|
2075
|
+
className: cn("openpkg-method-notes", "list-disc list-inside", "text-[15px] leading-relaxed", "text-[var(--openpkg-text-secondary)]", "mb-8 space-y-2"),
|
|
2076
|
+
children: notes.map((note, i) => /* @__PURE__ */ jsx40("li", {
|
|
2077
|
+
children: note
|
|
2078
|
+
}, i))
|
|
2079
|
+
}),
|
|
2080
|
+
children && /* @__PURE__ */ jsxs22("div", {
|
|
2081
|
+
className: "openpkg-method-params",
|
|
2082
|
+
children: [
|
|
2083
|
+
/* @__PURE__ */ jsx40("h3", {
|
|
2084
|
+
className: cn("text-xs font-semibold uppercase tracking-wider", "text-[var(--openpkg-text-muted)]", "mb-4 pb-2", "border-b border-[var(--openpkg-border-subtle)]"),
|
|
2085
|
+
children: "Parameters"
|
|
2086
|
+
}),
|
|
2087
|
+
children
|
|
2088
|
+
]
|
|
2089
|
+
})
|
|
2090
|
+
]
|
|
2091
|
+
});
|
|
2092
|
+
}
|
|
2093
|
+
function useSyncScrollSafe2() {
|
|
2094
|
+
try {
|
|
2095
|
+
return useSyncScroll();
|
|
2096
|
+
} catch {
|
|
2097
|
+
return null;
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
// src/docskit/api/parameter-list.tsx
|
|
2101
|
+
import { ChevronDown as ChevronDown2 } from "lucide-react";
|
|
2102
|
+
import * as React6 from "react";
|
|
2103
|
+
import { useState as useState11 } from "react";
|
|
2104
|
+
import { jsx as jsx41, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
2105
|
+
|
|
2106
|
+
function ParameterList({
|
|
2107
|
+
title,
|
|
2108
|
+
collapseAfter,
|
|
2109
|
+
children,
|
|
2110
|
+
className
|
|
2111
|
+
}) {
|
|
2112
|
+
const [expanded, setExpanded] = useState11(false);
|
|
2113
|
+
const childArray = React6.Children.toArray(children);
|
|
2114
|
+
const shouldCollapse = collapseAfter !== undefined && childArray.length > collapseAfter;
|
|
2115
|
+
const visibleChildren = shouldCollapse && !expanded ? childArray.slice(0, collapseAfter) : childArray;
|
|
2116
|
+
const hiddenCount = shouldCollapse ? childArray.length - collapseAfter : 0;
|
|
2117
|
+
return /* @__PURE__ */ jsxs23("div", {
|
|
2118
|
+
className: cn("", className),
|
|
2119
|
+
children: [
|
|
2120
|
+
title && /* @__PURE__ */ jsx41("h3", {
|
|
1278
2121
|
className: "text-sm font-medium text-foreground mb-3 uppercase tracking-wide",
|
|
1279
2122
|
children: title
|
|
1280
2123
|
}),
|
|
1281
|
-
/* @__PURE__ */
|
|
2124
|
+
/* @__PURE__ */ jsx41("div", {
|
|
1282
2125
|
className: "divide-y divide-border border-t border-b border-border",
|
|
1283
2126
|
children: visibleChildren
|
|
1284
2127
|
}),
|
|
1285
|
-
shouldCollapse && !expanded && /* @__PURE__ */
|
|
2128
|
+
shouldCollapse && !expanded && /* @__PURE__ */ jsxs23("button", {
|
|
1286
2129
|
type: "button",
|
|
1287
2130
|
onClick: () => setExpanded(true),
|
|
1288
2131
|
className: "flex items-center gap-1 mt-3 text-sm text-primary hover:underline cursor-pointer",
|
|
1289
2132
|
children: [
|
|
1290
|
-
/* @__PURE__ */
|
|
2133
|
+
/* @__PURE__ */ jsx41(ChevronDown2, {
|
|
1291
2134
|
size: 14
|
|
1292
2135
|
}),
|
|
1293
2136
|
"Show ",
|
|
@@ -1300,781 +2143,178 @@ function ParameterList({
|
|
|
1300
2143
|
});
|
|
1301
2144
|
}
|
|
1302
2145
|
// src/docskit/api/response-block.tsx
|
|
1303
|
-
import { Check as
|
|
1304
|
-
import
|
|
1305
|
-
import {
|
|
1306
|
-
import { jsx as jsx27, jsxs as jsxs16, Fragment as Fragment4 } from "react/jsx-runtime";
|
|
2146
|
+
import { Check as Check3, Copy as Copy3 } from "lucide-react";
|
|
2147
|
+
import { useState as useState12 } from "react";
|
|
2148
|
+
import { jsx as jsx42, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
1307
2149
|
|
|
1308
2150
|
function ResponseBlock({ data, title, className }) {
|
|
1309
|
-
const [copied, setCopied] =
|
|
2151
|
+
const [copied, setCopied] = useState12(false);
|
|
1310
2152
|
const jsonString = JSON.stringify(data, null, 2);
|
|
1311
2153
|
const handleCopy = () => {
|
|
1312
2154
|
navigator.clipboard.writeText(jsonString);
|
|
1313
2155
|
setCopied(true);
|
|
1314
2156
|
setTimeout(() => setCopied(false), 1200);
|
|
1315
2157
|
};
|
|
1316
|
-
return /* @__PURE__ */
|
|
2158
|
+
return /* @__PURE__ */ jsxs24("div", {
|
|
1317
2159
|
className: cn("group rounded-lg border border-border overflow-hidden bg-muted/30", className),
|
|
1318
2160
|
children: [
|
|
1319
|
-
title && /* @__PURE__ */
|
|
2161
|
+
title && /* @__PURE__ */ jsxs24("div", {
|
|
1320
2162
|
className: "flex items-center justify-between px-4 py-2 border-b border-border bg-muted/50",
|
|
1321
2163
|
children: [
|
|
1322
|
-
/* @__PURE__ */
|
|
2164
|
+
/* @__PURE__ */ jsx42("span", {
|
|
1323
2165
|
className: "text-xs font-medium text-muted-foreground uppercase tracking-wide",
|
|
1324
2166
|
children: title
|
|
1325
2167
|
}),
|
|
1326
|
-
/* @__PURE__ */
|
|
2168
|
+
/* @__PURE__ */ jsx42("button", {
|
|
1327
2169
|
type: "button",
|
|
1328
2170
|
onClick: handleCopy,
|
|
1329
2171
|
className: "p-1 rounded text-muted-foreground hover:text-foreground opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",
|
|
1330
2172
|
"aria-label": "Copy response",
|
|
1331
|
-
children: copied ? /* @__PURE__ */
|
|
2173
|
+
children: copied ? /* @__PURE__ */ jsx42(Check3, {
|
|
1332
2174
|
size: 14
|
|
1333
|
-
}) : /* @__PURE__ */
|
|
2175
|
+
}) : /* @__PURE__ */ jsx42(Copy3, {
|
|
1334
2176
|
size: 14
|
|
1335
2177
|
})
|
|
1336
2178
|
})
|
|
1337
2179
|
]
|
|
1338
2180
|
}),
|
|
1339
|
-
/* @__PURE__ */
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
json: data
|
|
1347
|
-
})
|
|
1348
|
-
})
|
|
1349
|
-
}),
|
|
1350
|
-
!title && /* @__PURE__ */ jsx27("button", {
|
|
1351
|
-
type: "button",
|
|
1352
|
-
onClick: handleCopy,
|
|
1353
|
-
className: "absolute top-3 right-3 p-1.5 rounded text-muted-foreground hover:text-foreground opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",
|
|
1354
|
-
"aria-label": "Copy response",
|
|
1355
|
-
children: copied ? /* @__PURE__ */ jsx27(Check4, {
|
|
1356
|
-
size: 14
|
|
1357
|
-
}) : /* @__PURE__ */ jsx27(Copy4, {
|
|
1358
|
-
size: 14
|
|
1359
|
-
})
|
|
1360
|
-
})
|
|
1361
|
-
]
|
|
2181
|
+
/* @__PURE__ */ jsx42(ClientDocsKitCode, {
|
|
2182
|
+
codeblock: {
|
|
2183
|
+
value: jsonString,
|
|
2184
|
+
lang: "json",
|
|
2185
|
+
meta: title ? "" : "-c"
|
|
2186
|
+
},
|
|
2187
|
+
className: "!my-0 !border-0 !rounded-none"
|
|
1362
2188
|
})
|
|
1363
2189
|
]
|
|
1364
2190
|
});
|
|
1365
2191
|
}
|
|
1366
|
-
function JsonHighlight({ json, depth = 0 }) {
|
|
1367
|
-
const indent = " ".repeat(depth);
|
|
1368
|
-
const nextIndent = " ".repeat(depth + 1);
|
|
1369
|
-
if (json === null) {
|
|
1370
|
-
return /* @__PURE__ */ jsx27("span", {
|
|
1371
|
-
className: "text-orange-400",
|
|
1372
|
-
children: "null"
|
|
1373
|
-
});
|
|
1374
|
-
}
|
|
1375
|
-
if (typeof json === "boolean") {
|
|
1376
|
-
return /* @__PURE__ */ jsx27("span", {
|
|
1377
|
-
className: "text-orange-400",
|
|
1378
|
-
children: json ? "true" : "false"
|
|
1379
|
-
});
|
|
1380
|
-
}
|
|
1381
|
-
if (typeof json === "number") {
|
|
1382
|
-
return /* @__PURE__ */ jsx27("span", {
|
|
1383
|
-
className: "text-cyan-400",
|
|
1384
|
-
children: json
|
|
1385
|
-
});
|
|
1386
|
-
}
|
|
1387
|
-
if (typeof json === "string") {
|
|
1388
|
-
return /* @__PURE__ */ jsxs16("span", {
|
|
1389
|
-
className: "text-emerald-400",
|
|
1390
|
-
children: [
|
|
1391
|
-
'"',
|
|
1392
|
-
json,
|
|
1393
|
-
'"'
|
|
1394
|
-
]
|
|
1395
|
-
});
|
|
1396
|
-
}
|
|
1397
|
-
if (Array.isArray(json)) {
|
|
1398
|
-
if (json.length === 0) {
|
|
1399
|
-
return /* @__PURE__ */ jsx27("span", {
|
|
1400
|
-
className: "text-foreground",
|
|
1401
|
-
children: "[]"
|
|
1402
|
-
});
|
|
1403
|
-
}
|
|
1404
|
-
return /* @__PURE__ */ jsxs16(Fragment4, {
|
|
1405
|
-
children: [
|
|
1406
|
-
/* @__PURE__ */ jsx27("span", {
|
|
1407
|
-
className: "text-foreground",
|
|
1408
|
-
children: "["
|
|
1409
|
-
}),
|
|
1410
|
-
`
|
|
1411
|
-
`,
|
|
1412
|
-
json.map((item, i) => /* @__PURE__ */ jsxs16(React6.Fragment, {
|
|
1413
|
-
children: [
|
|
1414
|
-
nextIndent,
|
|
1415
|
-
/* @__PURE__ */ jsx27(JsonHighlight, {
|
|
1416
|
-
json: item,
|
|
1417
|
-
depth: depth + 1
|
|
1418
|
-
}),
|
|
1419
|
-
i < json.length - 1 && /* @__PURE__ */ jsx27("span", {
|
|
1420
|
-
className: "text-foreground",
|
|
1421
|
-
children: ","
|
|
1422
|
-
}),
|
|
1423
|
-
`
|
|
1424
|
-
`
|
|
1425
|
-
]
|
|
1426
|
-
}, i)),
|
|
1427
|
-
indent,
|
|
1428
|
-
/* @__PURE__ */ jsx27("span", {
|
|
1429
|
-
className: "text-foreground",
|
|
1430
|
-
children: "]"
|
|
1431
|
-
})
|
|
1432
|
-
]
|
|
1433
|
-
});
|
|
1434
|
-
}
|
|
1435
|
-
if (typeof json === "object") {
|
|
1436
|
-
const entries = Object.entries(json);
|
|
1437
|
-
if (entries.length === 0) {
|
|
1438
|
-
return /* @__PURE__ */ jsx27("span", {
|
|
1439
|
-
className: "text-foreground",
|
|
1440
|
-
children: "{}"
|
|
1441
|
-
});
|
|
1442
|
-
}
|
|
1443
|
-
return /* @__PURE__ */ jsxs16(Fragment4, {
|
|
1444
|
-
children: [
|
|
1445
|
-
/* @__PURE__ */ jsx27("span", {
|
|
1446
|
-
className: "text-foreground",
|
|
1447
|
-
children: "{"
|
|
1448
|
-
}),
|
|
1449
|
-
`
|
|
1450
|
-
`,
|
|
1451
|
-
entries.map(([key, value], i) => /* @__PURE__ */ jsxs16(React6.Fragment, {
|
|
1452
|
-
children: [
|
|
1453
|
-
nextIndent,
|
|
1454
|
-
/* @__PURE__ */ jsxs16("span", {
|
|
1455
|
-
className: "text-blue-400",
|
|
1456
|
-
children: [
|
|
1457
|
-
'"',
|
|
1458
|
-
key,
|
|
1459
|
-
'"'
|
|
1460
|
-
]
|
|
1461
|
-
}),
|
|
1462
|
-
/* @__PURE__ */ jsx27("span", {
|
|
1463
|
-
className: "text-foreground",
|
|
1464
|
-
children: ": "
|
|
1465
|
-
}),
|
|
1466
|
-
/* @__PURE__ */ jsx27(JsonHighlight, {
|
|
1467
|
-
json: value,
|
|
1468
|
-
depth: depth + 1
|
|
1469
|
-
}),
|
|
1470
|
-
i < entries.length - 1 && /* @__PURE__ */ jsx27("span", {
|
|
1471
|
-
className: "text-foreground",
|
|
1472
|
-
children: ","
|
|
1473
|
-
}),
|
|
1474
|
-
`
|
|
1475
|
-
`
|
|
1476
|
-
]
|
|
1477
|
-
}, key)),
|
|
1478
|
-
indent,
|
|
1479
|
-
/* @__PURE__ */ jsx27("span", {
|
|
1480
|
-
className: "text-foreground",
|
|
1481
|
-
children: "}"
|
|
1482
|
-
})
|
|
1483
|
-
]
|
|
1484
|
-
});
|
|
1485
|
-
}
|
|
1486
|
-
return /* @__PURE__ */ jsx27("span", {
|
|
1487
|
-
className: "text-foreground",
|
|
1488
|
-
children: String(json)
|
|
1489
|
-
});
|
|
1490
|
-
}
|
|
1491
2192
|
// src/docskit/code.tsx
|
|
1492
2193
|
import { highlight as highlight2, Pre as Pre2 } from "codehike/code";
|
|
1493
|
-
|
|
1494
|
-
// src/docskit/code.copy.tsx
|
|
1495
|
-
import { Check as Check5, Copy as Copy5 } from "lucide-react";
|
|
1496
|
-
import { useState as useState8 } from "react";
|
|
1497
|
-
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
1498
|
-
|
|
1499
|
-
function CopyButton({
|
|
1500
|
-
text,
|
|
1501
|
-
className,
|
|
1502
|
-
variant = "floating"
|
|
1503
|
-
}) {
|
|
1504
|
-
const [copied, setCopied] = useState8(false);
|
|
1505
|
-
return /* @__PURE__ */ jsx28("button", {
|
|
1506
|
-
type: "button",
|
|
1507
|
-
className: cn("cursor-pointer transition-opacity duration-200", variant === "floating" && [
|
|
1508
|
-
"size-8 flex items-center justify-center",
|
|
1509
|
-
"rounded border border-openpkg-code-border bg-openpkg-code-bg",
|
|
1510
|
-
"opacity-0 group-hover:opacity-100"
|
|
1511
|
-
], variant === "inline" && "rounded", className),
|
|
1512
|
-
onClick: () => {
|
|
1513
|
-
navigator.clipboard.writeText(text);
|
|
1514
|
-
setCopied(true);
|
|
1515
|
-
setTimeout(() => setCopied(false), 1200);
|
|
1516
|
-
},
|
|
1517
|
-
"aria-label": "Copy to clipboard",
|
|
1518
|
-
children: copied ? /* @__PURE__ */ jsx28(Check5, {
|
|
1519
|
-
size: 16,
|
|
1520
|
-
className: "block"
|
|
1521
|
-
}) : /* @__PURE__ */ jsx28(Copy5, {
|
|
1522
|
-
size: 16,
|
|
1523
|
-
className: "block"
|
|
1524
|
-
})
|
|
1525
|
-
});
|
|
1526
|
-
}
|
|
1527
|
-
|
|
1528
|
-
// src/docskit/code.icon.tsx
|
|
1529
|
-
import { TerminalIcon } from "lucide-react";
|
|
1530
|
-
import { themeIcons } from "seti-icons";
|
|
1531
|
-
import { jsx as jsx29 } from "react/jsx-runtime";
|
|
1532
|
-
function CodeIcon({
|
|
1533
|
-
title,
|
|
1534
|
-
lang,
|
|
1535
|
-
className
|
|
1536
|
-
}) {
|
|
1537
|
-
if (title?.toLowerCase() === "terminal output" || title?.toLowerCase() === "terminal" || lang === "sh" || lang === "shell" || lang === "bash") {
|
|
1538
|
-
return /* @__PURE__ */ jsx29(TerminalIcon, {
|
|
1539
|
-
size: 16,
|
|
1540
|
-
className,
|
|
1541
|
-
style: { marginTop: -3.5 }
|
|
1542
|
-
});
|
|
1543
|
-
}
|
|
1544
|
-
const ext = lang === "rust" ? "rs" : lang === "typescript" ? "ts" : lang;
|
|
1545
|
-
const filename = `x.${ext}`;
|
|
1546
|
-
const { svg } = getIcon(filename);
|
|
1547
|
-
const __html = svg.replace(/svg/, `svg fill='currentColor' style='margin: -4px; height: 24px; width: 24px;'`);
|
|
1548
|
-
return /* @__PURE__ */ jsx29("span", {
|
|
1549
|
-
className,
|
|
1550
|
-
children: /* @__PURE__ */ jsx29("span", {
|
|
1551
|
-
dangerouslySetInnerHTML: { __html },
|
|
1552
|
-
style: { display: "contents" }
|
|
1553
|
-
})
|
|
1554
|
-
});
|
|
1555
|
-
}
|
|
1556
|
-
var getIcon = themeIcons({
|
|
1557
|
-
white: "#d4d7d6",
|
|
1558
|
-
grey: "#4d5a5e",
|
|
1559
|
-
"grey-light": "#6d8086",
|
|
1560
|
-
blue: "#519aba",
|
|
1561
|
-
green: "#8dc149",
|
|
1562
|
-
orange: "#e37933",
|
|
1563
|
-
pink: "#f55385",
|
|
1564
|
-
purple: "#a074c4",
|
|
1565
|
-
red: "#cc3e44",
|
|
1566
|
-
yellow: "#cbcb41",
|
|
1567
|
-
ignore: "#41535b"
|
|
1568
|
-
});
|
|
1569
|
-
|
|
1570
|
-
// src/docskit/code.tsx
|
|
1571
|
-
import { jsx as jsx30, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2194
|
+
import { jsx as jsx43, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
1572
2195
|
async function DocsKitCode(props) {
|
|
1573
2196
|
const { codeblock, className, ...rest } = props;
|
|
1574
2197
|
const group = await toCodeGroup({ codeblocks: [codeblock], ...rest });
|
|
1575
|
-
return /* @__PURE__ */
|
|
1576
|
-
group,
|
|
1577
|
-
className
|
|
1578
|
-
});
|
|
1579
|
-
}
|
|
1580
|
-
async function SingleCode(props) {
|
|
1581
|
-
const { pre, title, code, icon: icon2, options } = props.group.tabs[0];
|
|
1582
|
-
const showCopy = options?.copyButton;
|
|
1583
|
-
return /* @__PURE__ */ jsxs17("div", {
|
|
1584
|
-
className: cn("group rounded overflow-hidden relative border-openpkg-code-border flex flex-col border my-4 not-prose", props.className),
|
|
1585
|
-
children: [
|
|
1586
|
-
title ? /* @__PURE__ */ jsx30("div", {
|
|
1587
|
-
className: cn("border-b-[1px] border-openpkg-code-border bg-openpkg-code-header px-3 py-0", "w-full h-9 flex items-center shrink-0", "text-openpkg-code-text-inactive text-sm font-mono"),
|
|
1588
|
-
children: /* @__PURE__ */ jsxs17("div", {
|
|
1589
|
-
className: "flex items-center h-5 gap-2",
|
|
1590
|
-
children: [
|
|
1591
|
-
/* @__PURE__ */ jsx30("div", {
|
|
1592
|
-
className: "size-4",
|
|
1593
|
-
children: icon2
|
|
1594
|
-
}),
|
|
1595
|
-
/* @__PURE__ */ jsx30("span", {
|
|
1596
|
-
className: "leading-none",
|
|
1597
|
-
children: title
|
|
1598
|
-
})
|
|
1599
|
-
]
|
|
1600
|
-
})
|
|
1601
|
-
}) : null,
|
|
1602
|
-
/* @__PURE__ */ jsxs17("div", {
|
|
1603
|
-
className: "relative flex items-start",
|
|
1604
|
-
children: [
|
|
1605
|
-
pre,
|
|
1606
|
-
showCopy && /* @__PURE__ */ jsx30(CopyButton, {
|
|
1607
|
-
text: code,
|
|
1608
|
-
variant: "floating",
|
|
1609
|
-
className: cn("absolute right-3 z-10 text-openpkg-code-text-inactive", title ? "top-3" : "top-1/2 -translate-y-1/2")
|
|
1610
|
-
})
|
|
1611
|
-
]
|
|
1612
|
-
})
|
|
1613
|
-
]
|
|
1614
|
-
});
|
|
1615
|
-
}
|
|
1616
|
-
async function toCodeGroup(props) {
|
|
1617
|
-
const rawFlags = props.flags?.startsWith("-") ? props.flags.slice(1) : props.flags;
|
|
1618
|
-
const groupOptions = flagsToOptions(rawFlags);
|
|
1619
|
-
const tabs = await Promise.all(props.codeblocks.map(async (tab) => {
|
|
1620
|
-
const { flags, title } = extractFlags(tab);
|
|
1621
|
-
const tabOptions = flagsToOptions(flags);
|
|
1622
|
-
const options = { ...groupOptions, ...tabOptions };
|
|
1623
|
-
const highlighted = await highlight2({ ...tab, lang: tab.lang || "txt" }, theme);
|
|
1624
|
-
const handlers = getHandlers(options);
|
|
1625
|
-
if (props.handlers) {
|
|
1626
|
-
handlers.push(...props.handlers);
|
|
1627
|
-
}
|
|
1628
|
-
const { background: _background, ...highlightedStyle } = highlighted.style;
|
|
1629
|
-
return {
|
|
1630
|
-
options,
|
|
1631
|
-
title,
|
|
1632
|
-
code: highlighted.code,
|
|
1633
|
-
icon: /* @__PURE__ */ jsx30(CodeIcon, {
|
|
1634
|
-
title,
|
|
1635
|
-
lang: tab.lang,
|
|
1636
|
-
className: "opacity-60"
|
|
1637
|
-
}),
|
|
1638
|
-
lang: tab.lang,
|
|
1639
|
-
pre: /* @__PURE__ */ jsx30(Pre2, {
|
|
1640
|
-
code: highlighted,
|
|
1641
|
-
className: "overflow-auto px-0 py-3 m-0 rounded-none !bg-openpkg-code-bg selection:bg-openpkg-code-selection selection:text-current max-h-full flex-1",
|
|
1642
|
-
style: highlightedStyle,
|
|
1643
|
-
handlers
|
|
1644
|
-
})
|
|
1645
|
-
};
|
|
1646
|
-
}));
|
|
1647
|
-
return {
|
|
1648
|
-
storage: props.storage,
|
|
1649
|
-
options: groupOptions,
|
|
1650
|
-
tabs
|
|
1651
|
-
};
|
|
1652
|
-
}
|
|
1653
|
-
function extractFlags(codeblock) {
|
|
1654
|
-
const flags = codeblock.meta.split(" ").filter((flag) => flag.startsWith("-"))[0] ?? "";
|
|
1655
|
-
const metaWithoutFlags = !flags ? codeblock.meta : codeblock.meta === flags ? "" : codeblock.meta.replace(` ${flags}`, "").trim();
|
|
1656
|
-
const title = metaWithoutFlags.trim();
|
|
1657
|
-
return { title, flags: flags.slice(1) };
|
|
1658
|
-
}
|
|
1659
|
-
// src/hooks/use-local-storage.ts
|
|
1660
|
-
import React7 from "react";
|
|
1661
|
-
function useStateOrLocalStorage(key, initialState) {
|
|
1662
|
-
const [state, setState] = React7.useState(initialState);
|
|
1663
|
-
React7.useLayoutEffect(() => {
|
|
1664
|
-
if (!key)
|
|
1665
|
-
return;
|
|
1666
|
-
const storedValue = window.localStorage.getItem(key);
|
|
1667
|
-
if (storedValue != null) {
|
|
1668
|
-
setState(storedValue);
|
|
1669
|
-
}
|
|
1670
|
-
const onStorageChange = (e) => {
|
|
1671
|
-
if (e.key === key) {
|
|
1672
|
-
const storedValue2 = window.localStorage.getItem(key);
|
|
1673
|
-
setState(storedValue2 || initialState);
|
|
1674
|
-
}
|
|
1675
|
-
};
|
|
1676
|
-
window.addEventListener("storage", onStorageChange);
|
|
1677
|
-
return () => window.removeEventListener("storage", onStorageChange);
|
|
1678
|
-
}, [key, initialState]);
|
|
1679
|
-
const setStorage = !key ? setState : (value) => {
|
|
1680
|
-
if (typeof window !== "undefined") {
|
|
1681
|
-
window.localStorage.setItem(key, value);
|
|
1682
|
-
window.dispatchEvent(new StorageEvent("storage", { key }));
|
|
1683
|
-
}
|
|
1684
|
-
};
|
|
1685
|
-
return [state, setStorage];
|
|
1686
|
-
}
|
|
1687
|
-
|
|
1688
|
-
// src/docskit/tabs.tsx
|
|
1689
|
-
import * as TabsPrimitive from "@radix-ui/react-tabs";
|
|
1690
|
-
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
1691
|
-
|
|
1692
|
-
function Tabs({ className, ...props }) {
|
|
1693
|
-
return /* @__PURE__ */ jsx31(TabsPrimitive.Root, {
|
|
1694
|
-
"data-slot": "tabs",
|
|
1695
|
-
className: cn("flex flex-col gap-2", className),
|
|
1696
|
-
...props
|
|
1697
|
-
});
|
|
1698
|
-
}
|
|
1699
|
-
function TabsList({ className, ...props }) {
|
|
1700
|
-
return /* @__PURE__ */ jsx31(TabsPrimitive.List, {
|
|
1701
|
-
"data-slot": "tabs-list",
|
|
1702
|
-
className: cn("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]", className),
|
|
1703
|
-
...props
|
|
1704
|
-
});
|
|
1705
|
-
}
|
|
1706
|
-
function TabsTrigger({ className, ...props }) {
|
|
1707
|
-
return /* @__PURE__ */ jsx31(TabsPrimitive.Trigger, {
|
|
1708
|
-
"data-slot": "tabs-trigger",
|
|
1709
|
-
className: cn("dark:data-[state=active]:text-foreground focus-visible:ring-ring/50 focus-visible:outline-ring dark:text-muted-foreground inline-flex h-full flex-1 items-center justify-center gap-1.5 px-2 py-1 text-sm font-normal whitespace-nowrap transition-colors focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
|
|
1710
|
-
...props
|
|
1711
|
-
});
|
|
1712
|
-
}
|
|
1713
|
-
function TabsContent({ className, ...props }) {
|
|
1714
|
-
return /* @__PURE__ */ jsx31(TabsPrimitive.Content, {
|
|
1715
|
-
"data-slot": "tabs-content",
|
|
1716
|
-
className: cn("flex-1 outline-none", className),
|
|
1717
|
-
...props
|
|
1718
|
-
});
|
|
1719
|
-
}
|
|
1720
|
-
|
|
1721
|
-
// src/docskit/code.client.tsx
|
|
1722
|
-
import { jsx as jsx32, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
1723
|
-
|
|
1724
|
-
function MultiCode({ group, className }) {
|
|
1725
|
-
const [storedTitle, setCurrentTitle] = useStateOrLocalStorage(group.storage, group.tabs[0].title);
|
|
1726
|
-
const current = group.tabs.find((tab) => tab.title === storedTitle) || group.tabs[0];
|
|
1727
|
-
const { code } = current;
|
|
1728
|
-
const currentTitle = current?.title;
|
|
1729
|
-
return /* @__PURE__ */ jsxs18(Tabs, {
|
|
1730
|
-
value: currentTitle,
|
|
1731
|
-
onValueChange: setCurrentTitle,
|
|
1732
|
-
className: cn("group border rounded selection:bg-openpkg-code-selection selection:text-current border-openpkg-code-border overflow-hidden relative flex flex-col max-h-full min-h-0 my-4 gap-0 not-prose", className),
|
|
1733
|
-
children: [
|
|
1734
|
-
/* @__PURE__ */ jsx32(TabsList, {
|
|
1735
|
-
className: cn("border-b border-openpkg-code-border bg-openpkg-code-header w-full h-9 min-h-9 shrink-0", "rounded-none p-0 m-0 justify-start items-stretch"),
|
|
1736
|
-
children: group.tabs.map(({ icon: icon2, title }, _index) => /* @__PURE__ */ jsxs18(TabsTrigger, {
|
|
1737
|
-
value: title,
|
|
1738
|
-
className: cn("rounded-none transition-colors duration-200 gap-1.5 px-3 font-mono justify-start grow-0", "border-r border-openpkg-code-border", "text-openpkg-code-text-inactive data-[state=active]:text-openpkg-code-text-active hover:text-openpkg-code-text-active", "data-[state=active]:bg-openpkg-code-bg/50"),
|
|
1739
|
-
children: [
|
|
1740
|
-
/* @__PURE__ */ jsx32("div", {
|
|
1741
|
-
children: icon2
|
|
1742
|
-
}),
|
|
1743
|
-
/* @__PURE__ */ jsx32("span", {
|
|
1744
|
-
className: "leading-none",
|
|
1745
|
-
children: title
|
|
1746
|
-
})
|
|
1747
|
-
]
|
|
1748
|
-
}, title))
|
|
1749
|
-
}),
|
|
1750
|
-
/* @__PURE__ */ jsxs18(TabsContent, {
|
|
1751
|
-
value: current.title,
|
|
1752
|
-
className: "relative min-h-0 mt-0 flex flex-col",
|
|
1753
|
-
children: [
|
|
1754
|
-
current.pre,
|
|
1755
|
-
group.options.copyButton && /* @__PURE__ */ jsx32(CopyButton, {
|
|
1756
|
-
text: code,
|
|
1757
|
-
variant: "floating",
|
|
1758
|
-
className: "absolute right-3 top-3 z-10 text-openpkg-code-text-inactive"
|
|
1759
|
-
})
|
|
1760
|
-
]
|
|
1761
|
-
})
|
|
1762
|
-
]
|
|
1763
|
-
});
|
|
1764
|
-
}
|
|
1765
|
-
// src/docskit/code.client-highlight.tsx
|
|
1766
|
-
import {
|
|
1767
|
-
highlight as highlight3,
|
|
1768
|
-
Inline,
|
|
1769
|
-
Pre as Pre3
|
|
1770
|
-
} from "codehike/code";
|
|
1771
|
-
import { useEffect as useEffect3, useState as useState9 } from "react";
|
|
1772
|
-
import { jsx as jsx33, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
1773
|
-
|
|
1774
|
-
function ClientDocsKitCode(props) {
|
|
1775
|
-
const { codeblock, handlers: extraHandlers, className: wrapperClassName } = props;
|
|
1776
|
-
const [highlighted, setHighlighted] = useState9(null);
|
|
1777
|
-
const { title, flags } = extractFlags2(codeblock);
|
|
1778
|
-
const options = flagsToOptions(flags);
|
|
1779
|
-
useEffect3(() => {
|
|
1780
|
-
let cancelled = false;
|
|
1781
|
-
highlight3({ ...codeblock, lang: codeblock.lang || "txt" }, theme).then((result) => {
|
|
1782
|
-
if (!cancelled)
|
|
1783
|
-
setHighlighted(result);
|
|
1784
|
-
});
|
|
1785
|
-
return () => {
|
|
1786
|
-
cancelled = true;
|
|
1787
|
-
};
|
|
1788
|
-
}, [codeblock.value, codeblock.lang, codeblock.meta]);
|
|
1789
|
-
if (!highlighted) {
|
|
1790
|
-
return /* @__PURE__ */ jsx33(CodeBlockSkeleton, {
|
|
1791
|
-
hasTitle: !!title
|
|
1792
|
-
});
|
|
1793
|
-
}
|
|
1794
|
-
const handlers = getHandlers(options);
|
|
1795
|
-
if (extraHandlers) {
|
|
1796
|
-
handlers.push(...extraHandlers);
|
|
1797
|
-
}
|
|
1798
|
-
const { background: _background, ...highlightedStyle } = highlighted.style;
|
|
1799
|
-
const showCopy = options?.copyButton;
|
|
1800
|
-
const icon2 = /* @__PURE__ */ jsx33(CodeIcon, {
|
|
1801
|
-
title,
|
|
1802
|
-
lang: codeblock.lang,
|
|
1803
|
-
className: "opacity-60"
|
|
2198
|
+
return /* @__PURE__ */ jsx43(SingleCode, {
|
|
2199
|
+
group,
|
|
2200
|
+
className
|
|
1804
2201
|
});
|
|
1805
|
-
|
|
1806
|
-
|
|
2202
|
+
}
|
|
2203
|
+
async function SingleCode(props) {
|
|
2204
|
+
const { pre, title, code, icon: icon2, options } = props.group.tabs[0];
|
|
2205
|
+
const showCopy = options?.copyButton;
|
|
2206
|
+
return /* @__PURE__ */ jsxs25("div", {
|
|
2207
|
+
className: cn("group rounded overflow-hidden relative border-openpkg-code-border flex flex-col border my-4 not-prose", props.className),
|
|
1807
2208
|
children: [
|
|
1808
|
-
title ? /* @__PURE__ */
|
|
2209
|
+
title ? /* @__PURE__ */ jsx43("div", {
|
|
1809
2210
|
className: cn("border-b-[1px] border-openpkg-code-border bg-openpkg-code-header px-3 py-0", "w-full h-9 flex items-center shrink-0", "text-openpkg-code-text-inactive text-sm font-mono"),
|
|
1810
|
-
children: /* @__PURE__ */
|
|
2211
|
+
children: /* @__PURE__ */ jsxs25("div", {
|
|
1811
2212
|
className: "flex items-center h-5 gap-2",
|
|
1812
2213
|
children: [
|
|
1813
|
-
/* @__PURE__ */
|
|
2214
|
+
/* @__PURE__ */ jsx43("div", {
|
|
1814
2215
|
className: "size-4",
|
|
1815
2216
|
children: icon2
|
|
1816
2217
|
}),
|
|
1817
|
-
/* @__PURE__ */
|
|
2218
|
+
/* @__PURE__ */ jsx43("span", {
|
|
1818
2219
|
className: "leading-none",
|
|
1819
2220
|
children: title
|
|
1820
2221
|
})
|
|
1821
2222
|
]
|
|
1822
2223
|
})
|
|
1823
2224
|
}) : null,
|
|
1824
|
-
/* @__PURE__ */
|
|
2225
|
+
/* @__PURE__ */ jsxs25("div", {
|
|
1825
2226
|
className: "relative flex items-start",
|
|
1826
2227
|
children: [
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
style: highlightedStyle,
|
|
1831
|
-
handlers
|
|
1832
|
-
}),
|
|
1833
|
-
showCopy && /* @__PURE__ */ jsx33(CopyButton, {
|
|
1834
|
-
text: highlighted.code,
|
|
2228
|
+
pre,
|
|
2229
|
+
showCopy && /* @__PURE__ */ jsx43(CopyButton, {
|
|
2230
|
+
text: code,
|
|
1835
2231
|
variant: "floating",
|
|
1836
|
-
className: cn("absolute right-3 z-10 text-openpkg-code-text-inactive",
|
|
2232
|
+
className: cn("absolute right-3 z-10 text-openpkg-code-text-inactive", "top-3")
|
|
1837
2233
|
})
|
|
1838
2234
|
]
|
|
1839
2235
|
})
|
|
1840
2236
|
]
|
|
1841
2237
|
});
|
|
1842
2238
|
}
|
|
1843
|
-
function
|
|
1844
|
-
const
|
|
1845
|
-
const
|
|
1846
|
-
const
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
}
|
|
1865
|
-
const { background: _background, ...highlightedStyle } = highlighted.style;
|
|
1866
|
-
const showCopy = options?.copyButton;
|
|
1867
|
-
const isMultiLine = highlighted.code.includes(`
|
|
1868
|
-
`);
|
|
1869
|
-
return /* @__PURE__ */ jsxs19("div", {
|
|
1870
|
-
className: "group rounded overflow-hidden relative border-openpkg-code-border flex flex-col border my-4 not-prose",
|
|
1871
|
-
children: [
|
|
1872
|
-
/* @__PURE__ */ jsxs19("div", {
|
|
1873
|
-
className: cn("border-b border-openpkg-code-border bg-openpkg-code-header", "w-full h-9 flex items-center justify-center shrink-0", "relative"),
|
|
1874
|
-
children: [
|
|
1875
|
-
/* @__PURE__ */ jsxs19("div", {
|
|
1876
|
-
className: "absolute left-3 flex items-center gap-2",
|
|
1877
|
-
children: [
|
|
1878
|
-
/* @__PURE__ */ jsx33("div", {
|
|
1879
|
-
className: "size-3 rounded-full bg-openpkg-code-text-inactive/30"
|
|
1880
|
-
}),
|
|
1881
|
-
/* @__PURE__ */ jsx33("div", {
|
|
1882
|
-
className: "size-3 rounded-full bg-openpkg-code-text-inactive/30"
|
|
1883
|
-
}),
|
|
1884
|
-
/* @__PURE__ */ jsx33("div", {
|
|
1885
|
-
className: "size-3 rounded-full bg-openpkg-code-text-inactive/30"
|
|
1886
|
-
})
|
|
1887
|
-
]
|
|
1888
|
-
}),
|
|
1889
|
-
/* @__PURE__ */ jsx33("span", {
|
|
1890
|
-
className: "sr-only",
|
|
1891
|
-
children: "Terminal window"
|
|
1892
|
-
})
|
|
1893
|
-
]
|
|
2239
|
+
async function toCodeGroup(props) {
|
|
2240
|
+
const rawFlags = props.flags?.startsWith("-") ? props.flags.slice(1) : props.flags;
|
|
2241
|
+
const groupOptions = flagsToOptions(rawFlags);
|
|
2242
|
+
const tabs = await Promise.all(props.codeblocks.map(async (tab) => {
|
|
2243
|
+
const { flags, title } = extractFlags2(tab);
|
|
2244
|
+
const tabOptions = flagsToOptions(flags);
|
|
2245
|
+
const options = { ...groupOptions, ...tabOptions };
|
|
2246
|
+
const highlighted = await highlight2({ ...tab, lang: tab.lang || "txt" }, theme);
|
|
2247
|
+
const handlers = getHandlers(options);
|
|
2248
|
+
if (props.handlers) {
|
|
2249
|
+
handlers.push(...props.handlers);
|
|
2250
|
+
}
|
|
2251
|
+
const { background: _background, ...highlightedStyle } = highlighted.style;
|
|
2252
|
+
return {
|
|
2253
|
+
options,
|
|
2254
|
+
title,
|
|
2255
|
+
code: highlighted.code,
|
|
2256
|
+
icon: /* @__PURE__ */ jsx43(CodeIcon, {
|
|
2257
|
+
title,
|
|
2258
|
+
lang: tab.lang,
|
|
2259
|
+
className: "opacity-60"
|
|
1894
2260
|
}),
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
style: highlightedStyle,
|
|
1902
|
-
handlers
|
|
1903
|
-
}),
|
|
1904
|
-
showCopy && /* @__PURE__ */ jsx33(CopyButton, {
|
|
1905
|
-
text: highlighted.code,
|
|
1906
|
-
variant: "floating",
|
|
1907
|
-
className: cn("absolute right-3 z-10 text-openpkg-code-text-inactive", isMultiLine ? "top-3" : "top-1/2 -translate-y-1/2")
|
|
1908
|
-
})
|
|
1909
|
-
]
|
|
2261
|
+
lang: tab.lang,
|
|
2262
|
+
pre: /* @__PURE__ */ jsx43(Pre2, {
|
|
2263
|
+
code: highlighted,
|
|
2264
|
+
className: "overflow-auto px-0 py-3 m-0 rounded-none !bg-openpkg-code-bg selection:bg-openpkg-code-selection selection:text-current max-h-full flex-1",
|
|
2265
|
+
style: highlightedStyle,
|
|
2266
|
+
handlers
|
|
1910
2267
|
})
|
|
1911
|
-
]
|
|
1912
|
-
});
|
|
1913
|
-
}
|
|
1914
|
-
function ClientInlineCode({ codeblock }) {
|
|
1915
|
-
const [highlighted, setHighlighted] = useState9(null);
|
|
1916
|
-
useEffect3(() => {
|
|
1917
|
-
let cancelled = false;
|
|
1918
|
-
highlight3(codeblock, theme).then((result) => {
|
|
1919
|
-
if (!cancelled)
|
|
1920
|
-
setHighlighted(result);
|
|
1921
|
-
});
|
|
1922
|
-
return () => {
|
|
1923
|
-
cancelled = true;
|
|
1924
2268
|
};
|
|
1925
|
-
}
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
className: "selection:bg-openpkg-code-selection selection:text-current rounded border border-openpkg-code-border px-1 py-0.5 whitespace-nowrap !bg-openpkg-code-bg",
|
|
1932
|
-
style: highlighted.style
|
|
1933
|
-
});
|
|
2269
|
+
}));
|
|
2270
|
+
return {
|
|
2271
|
+
storage: props.storage,
|
|
2272
|
+
options: groupOptions,
|
|
2273
|
+
tabs
|
|
2274
|
+
};
|
|
1934
2275
|
}
|
|
1935
2276
|
function extractFlags2(codeblock) {
|
|
1936
|
-
const
|
|
1937
|
-
const
|
|
1938
|
-
const metaWithoutFlags = !flags ? meta : meta === flags ? "" : meta.replace(` ${flags}`, "").trim();
|
|
2277
|
+
const flags = codeblock.meta.split(" ").filter((flag) => flag.startsWith("-"))[0] ?? "";
|
|
2278
|
+
const metaWithoutFlags = !flags ? codeblock.meta : codeblock.meta === flags ? "" : codeblock.meta.replace(` ${flags}`, "").trim();
|
|
1939
2279
|
const title = metaWithoutFlags.trim();
|
|
1940
2280
|
return { title, flags: flags.slice(1) };
|
|
1941
2281
|
}
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
const
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
const _codeBlocksKey = codeblocks.map((b) => `${b.value}|${b.lang}|${b.meta}`).join("::");
|
|
1953
|
-
useEffect3(() => {
|
|
1954
|
-
let cancelled = false;
|
|
1955
|
-
Promise.all(codeblocks.map(async (block, index) => {
|
|
1956
|
-
const { title, flags } = extractFlags2(block);
|
|
1957
|
-
const tabOptions = flagsToOptions(flags);
|
|
1958
|
-
const options = { ...groupOptions, ...tabOptions };
|
|
1959
|
-
const result = await highlight3({ ...block, lang: block.lang || "txt" }, theme);
|
|
1960
|
-
return {
|
|
1961
|
-
index,
|
|
1962
|
-
highlighted: result,
|
|
1963
|
-
title,
|
|
1964
|
-
options,
|
|
1965
|
-
icon: /* @__PURE__ */ jsx33(CodeIcon, {
|
|
1966
|
-
title,
|
|
1967
|
-
lang: block.lang,
|
|
1968
|
-
className: "opacity-60"
|
|
1969
|
-
})
|
|
1970
|
-
};
|
|
1971
|
-
})).then((results) => {
|
|
1972
|
-
if (!cancelled) {
|
|
1973
|
-
const map = new Map;
|
|
1974
|
-
results.forEach((r) => map.set(r.index, r));
|
|
1975
|
-
setHighlighted(map);
|
|
1976
|
-
}
|
|
1977
|
-
});
|
|
1978
|
-
return () => {
|
|
1979
|
-
cancelled = true;
|
|
1980
|
-
};
|
|
1981
|
-
}, [_codeBlocksKey]);
|
|
1982
|
-
if (!highlighted) {
|
|
1983
|
-
return /* @__PURE__ */ jsx33(CodeTabsSkeleton, {
|
|
1984
|
-
tabs: codeblocks.length
|
|
1985
|
-
});
|
|
1986
|
-
}
|
|
1987
|
-
if (codeblocks.length === 1) {
|
|
1988
|
-
const tab = highlighted.get(0);
|
|
1989
|
-
const handlers = getHandlers(tab.options);
|
|
1990
|
-
const { background: _background, ...highlightedStyle } = tab.highlighted.style;
|
|
1991
|
-
return /* @__PURE__ */ jsxs19("div", {
|
|
1992
|
-
className: "group rounded overflow-hidden relative border-openpkg-code-border flex flex-col border my-4 not-prose",
|
|
1993
|
-
children: [
|
|
1994
|
-
tab.title ? /* @__PURE__ */ jsx33("div", {
|
|
1995
|
-
className: cn("border-b-[1px] border-openpkg-code-border bg-openpkg-code-header px-3 py-0", "w-full h-9 flex items-center shrink-0", "text-openpkg-code-text-inactive text-sm font-mono"),
|
|
1996
|
-
children: /* @__PURE__ */ jsxs19("div", {
|
|
1997
|
-
className: "flex items-center h-5 gap-2",
|
|
1998
|
-
children: [
|
|
1999
|
-
/* @__PURE__ */ jsx33("div", {
|
|
2000
|
-
className: "size-4",
|
|
2001
|
-
children: tab.icon
|
|
2002
|
-
}),
|
|
2003
|
-
/* @__PURE__ */ jsx33("span", {
|
|
2004
|
-
className: "leading-none",
|
|
2005
|
-
children: tab.title
|
|
2006
|
-
})
|
|
2007
|
-
]
|
|
2008
|
-
})
|
|
2009
|
-
}) : null,
|
|
2010
|
-
/* @__PURE__ */ jsxs19("div", {
|
|
2011
|
-
className: "relative flex items-start",
|
|
2012
|
-
children: [
|
|
2013
|
-
/* @__PURE__ */ jsx33(Pre3, {
|
|
2014
|
-
code: tab.highlighted,
|
|
2015
|
-
className: "overflow-auto px-0 py-3 m-0 rounded-none !bg-openpkg-code-bg selection:bg-openpkg-code-selection selection:text-current max-h-full flex-1",
|
|
2016
|
-
style: highlightedStyle,
|
|
2017
|
-
handlers
|
|
2018
|
-
}),
|
|
2019
|
-
tab.options.copyButton && /* @__PURE__ */ jsx33(CopyButton, {
|
|
2020
|
-
text: tab.highlighted.code,
|
|
2021
|
-
variant: "floating",
|
|
2022
|
-
className: "absolute right-3 top-3 z-10 text-openpkg-code-text-inactive"
|
|
2023
|
-
})
|
|
2024
|
-
]
|
|
2025
|
-
})
|
|
2026
|
-
]
|
|
2027
|
-
});
|
|
2028
|
-
}
|
|
2029
|
-
return /* @__PURE__ */ jsx33(ClientMultiCode, {
|
|
2030
|
-
highlighted,
|
|
2031
|
-
groupOptions,
|
|
2032
|
-
storage
|
|
2033
|
-
});
|
|
2034
|
-
}
|
|
2035
|
-
function ClientMultiCode({
|
|
2036
|
-
highlighted,
|
|
2037
|
-
groupOptions,
|
|
2038
|
-
storage
|
|
2039
|
-
}) {
|
|
2040
|
-
const tabs = Array.from(highlighted.values());
|
|
2041
|
-
const [storedTitle, setCurrentTitle] = useStateOrLocalStorage(storage, tabs[0].title);
|
|
2042
|
-
const current = tabs.find((tab) => tab.title === storedTitle) || tabs[0];
|
|
2043
|
-
const handlers = getHandlers(current.options);
|
|
2044
|
-
const { background: _background, ...highlightedStyle } = current.highlighted.style;
|
|
2045
|
-
return /* @__PURE__ */ jsxs19(Tabs, {
|
|
2046
|
-
value: current.title,
|
|
2282
|
+
// src/docskit/code.client.tsx
|
|
2283
|
+
import { jsx as jsx44, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
2284
|
+
|
|
2285
|
+
function MultiCode({ group, className }) {
|
|
2286
|
+
const [storedTitle, setCurrentTitle] = useStateOrLocalStorage(group.storage, group.tabs[0].title);
|
|
2287
|
+
const current = group.tabs.find((tab) => tab.title === storedTitle) || group.tabs[0];
|
|
2288
|
+
const { code } = current;
|
|
2289
|
+
const currentTitle = current?.title;
|
|
2290
|
+
return /* @__PURE__ */ jsxs26(Tabs, {
|
|
2291
|
+
value: currentTitle,
|
|
2047
2292
|
onValueChange: setCurrentTitle,
|
|
2048
|
-
className: cn("group border rounded selection:bg-openpkg-code-selection selection:text-current border-openpkg-code-border overflow-hidden relative flex flex-col max-h-full min-h-0 my-4 gap-0 not-prose"),
|
|
2293
|
+
className: cn("group border rounded selection:bg-openpkg-code-selection selection:text-current border-openpkg-code-border overflow-hidden relative flex flex-col max-h-full min-h-0 my-4 gap-0 not-prose", className),
|
|
2049
2294
|
children: [
|
|
2050
|
-
/* @__PURE__ */
|
|
2295
|
+
/* @__PURE__ */ jsx44(TabsList, {
|
|
2051
2296
|
className: cn("border-b border-openpkg-code-border bg-openpkg-code-header w-full h-9 min-h-9 shrink-0", "rounded-none p-0 m-0 justify-start items-stretch"),
|
|
2052
|
-
children: tabs.map(({ icon: icon2, title }) => /* @__PURE__ */
|
|
2297
|
+
children: group.tabs.map(({ icon: icon2, title }, _index) => /* @__PURE__ */ jsxs26(TabsTrigger, {
|
|
2053
2298
|
value: title,
|
|
2054
2299
|
className: cn("rounded-none transition-colors duration-200 gap-1.5 px-3 font-mono justify-start grow-0", "border-r border-openpkg-code-border", "text-openpkg-code-text-inactive data-[state=active]:text-openpkg-code-text-active hover:text-openpkg-code-text-active", "data-[state=active]:bg-openpkg-code-bg/50"),
|
|
2055
2300
|
children: [
|
|
2056
|
-
/* @__PURE__ */
|
|
2301
|
+
/* @__PURE__ */ jsx44("div", {
|
|
2057
2302
|
children: icon2
|
|
2058
2303
|
}),
|
|
2059
|
-
/* @__PURE__ */
|
|
2304
|
+
/* @__PURE__ */ jsx44("span", {
|
|
2060
2305
|
className: "leading-none",
|
|
2061
2306
|
children: title
|
|
2062
2307
|
})
|
|
2063
2308
|
]
|
|
2064
2309
|
}, title))
|
|
2065
2310
|
}),
|
|
2066
|
-
/* @__PURE__ */
|
|
2311
|
+
/* @__PURE__ */ jsxs26(TabsContent, {
|
|
2067
2312
|
value: current.title,
|
|
2068
2313
|
className: "relative min-h-0 mt-0 flex flex-col",
|
|
2069
2314
|
children: [
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
style: highlightedStyle,
|
|
2074
|
-
handlers
|
|
2075
|
-
}),
|
|
2076
|
-
groupOptions.copyButton && /* @__PURE__ */ jsx33(CopyButton, {
|
|
2077
|
-
text: current.highlighted.code,
|
|
2315
|
+
current.pre,
|
|
2316
|
+
group.options.copyButton && /* @__PURE__ */ jsx44(CopyButton, {
|
|
2317
|
+
text: code,
|
|
2078
2318
|
variant: "floating",
|
|
2079
2319
|
className: "absolute right-3 top-3 z-10 text-openpkg-code-text-inactive"
|
|
2080
2320
|
})
|
|
@@ -2085,21 +2325,21 @@ function ClientMultiCode({
|
|
|
2085
2325
|
}
|
|
2086
2326
|
// src/docskit/code.diff.tsx
|
|
2087
2327
|
import {
|
|
2088
|
-
highlight as
|
|
2089
|
-
Pre as
|
|
2328
|
+
highlight as highlight3,
|
|
2329
|
+
Pre as Pre3
|
|
2090
2330
|
} from "codehike/code";
|
|
2091
2331
|
import { ChevronDown as ChevronDown3, ChevronUp } from "lucide-react";
|
|
2092
|
-
import { useEffect as
|
|
2093
|
-
import { jsx as
|
|
2332
|
+
import { useEffect as useEffect6, useState as useState13 } from "react";
|
|
2333
|
+
import { jsx as jsx45, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
2094
2334
|
|
|
2095
2335
|
function StackedChevrons({ isOpen, className }) {
|
|
2096
|
-
return /* @__PURE__ */
|
|
2336
|
+
return /* @__PURE__ */ jsxs27("div", {
|
|
2097
2337
|
className: cn("flex flex-col items-center -space-y-1 transition-opacity", className),
|
|
2098
2338
|
children: [
|
|
2099
|
-
/* @__PURE__ */
|
|
2339
|
+
/* @__PURE__ */ jsx45(ChevronUp, {
|
|
2100
2340
|
className: cn("size-3 transition-colors", isOpen ? "text-openpkg-code-text-active" : "text-openpkg-code-text-inactive")
|
|
2101
2341
|
}),
|
|
2102
|
-
/* @__PURE__ */
|
|
2342
|
+
/* @__PURE__ */ jsx45(ChevronDown3, {
|
|
2103
2343
|
className: cn("size-3 transition-colors", isOpen ? "text-openpkg-code-text-active" : "text-openpkg-code-text-inactive")
|
|
2104
2344
|
})
|
|
2105
2345
|
]
|
|
@@ -2115,14 +2355,14 @@ function ClientDiffCode(props) {
|
|
|
2115
2355
|
className: wrapperClassName,
|
|
2116
2356
|
defaultOpen = true
|
|
2117
2357
|
} = props;
|
|
2118
|
-
const [highlighted, setHighlighted] =
|
|
2119
|
-
const [isOpen, setIsOpen] =
|
|
2358
|
+
const [highlighted, setHighlighted] = useState13(null);
|
|
2359
|
+
const [isOpen, setIsOpen] = useState13(defaultOpen);
|
|
2120
2360
|
const { title, flags } = extractFlags3(codeblock);
|
|
2121
2361
|
const options = flagsToOptions(flags);
|
|
2122
2362
|
const filename = filenameProp || title || "file";
|
|
2123
|
-
|
|
2363
|
+
useEffect6(() => {
|
|
2124
2364
|
let cancelled = false;
|
|
2125
|
-
|
|
2365
|
+
highlight3({ ...codeblock, lang: codeblock.lang || "txt" }, theme).then((result) => {
|
|
2126
2366
|
if (!cancelled)
|
|
2127
2367
|
setHighlighted(result);
|
|
2128
2368
|
});
|
|
@@ -2131,7 +2371,7 @@ function ClientDiffCode(props) {
|
|
|
2131
2371
|
};
|
|
2132
2372
|
}, [codeblock.value, codeblock.lang, codeblock.meta, codeblock]);
|
|
2133
2373
|
if (!highlighted) {
|
|
2134
|
-
return /* @__PURE__ */
|
|
2374
|
+
return /* @__PURE__ */ jsx45(CodeBlockSkeleton, {
|
|
2135
2375
|
hasTitle: true
|
|
2136
2376
|
});
|
|
2137
2377
|
}
|
|
@@ -2141,53 +2381,53 @@ function ClientDiffCode(props) {
|
|
|
2141
2381
|
}
|
|
2142
2382
|
const { background: _background, ...highlightedStyle } = highlighted.style;
|
|
2143
2383
|
const showCopy = options?.copyButton;
|
|
2144
|
-
const icon2 = /* @__PURE__ */
|
|
2384
|
+
const icon2 = /* @__PURE__ */ jsx45(CodeIcon, {
|
|
2145
2385
|
title: filename,
|
|
2146
2386
|
lang: codeblock.lang,
|
|
2147
2387
|
className: "opacity-60"
|
|
2148
2388
|
});
|
|
2149
2389
|
const hasAdditions = diff2?.additions !== undefined && diff2.additions > 0;
|
|
2150
2390
|
const hasDeletions = diff2?.deletions !== undefined && diff2.deletions > 0;
|
|
2151
|
-
return /* @__PURE__ */
|
|
2391
|
+
return /* @__PURE__ */ jsx45(Collapsible, {
|
|
2152
2392
|
open: isOpen,
|
|
2153
2393
|
onOpenChange: setIsOpen,
|
|
2154
|
-
children: /* @__PURE__ */
|
|
2394
|
+
children: /* @__PURE__ */ jsxs27("div", {
|
|
2155
2395
|
className: cn("group rounded overflow-hidden relative border-openpkg-code-border flex flex-col border my-4 not-prose", wrapperClassName),
|
|
2156
2396
|
children: [
|
|
2157
|
-
/* @__PURE__ */
|
|
2397
|
+
/* @__PURE__ */ jsx45(CollapsibleTrigger2, {
|
|
2158
2398
|
asChild: true,
|
|
2159
|
-
children: /* @__PURE__ */
|
|
2399
|
+
children: /* @__PURE__ */ jsxs27("button", {
|
|
2160
2400
|
type: "button",
|
|
2161
2401
|
className: cn("border-b border-openpkg-code-border bg-openpkg-code-header px-3 py-0", "w-full h-9 flex items-center shrink-0 cursor-pointer", "text-openpkg-code-text-inactive text-sm font-mono", "hover:bg-openpkg-code-bg/50 transition-colors"),
|
|
2162
2402
|
children: [
|
|
2163
|
-
/* @__PURE__ */
|
|
2403
|
+
/* @__PURE__ */ jsxs27("div", {
|
|
2164
2404
|
className: "flex items-center h-5 gap-2 flex-1 min-w-0",
|
|
2165
2405
|
children: [
|
|
2166
|
-
/* @__PURE__ */
|
|
2406
|
+
/* @__PURE__ */ jsx45("div", {
|
|
2167
2407
|
className: "size-4 shrink-0",
|
|
2168
2408
|
children: icon2
|
|
2169
2409
|
}),
|
|
2170
|
-
path && /* @__PURE__ */
|
|
2410
|
+
path && /* @__PURE__ */ jsx45("span", {
|
|
2171
2411
|
className: "text-openpkg-code-text-inactive truncate",
|
|
2172
2412
|
children: path
|
|
2173
2413
|
}),
|
|
2174
|
-
/* @__PURE__ */
|
|
2414
|
+
/* @__PURE__ */ jsx45("span", {
|
|
2175
2415
|
className: "text-openpkg-code-text-active font-medium truncate",
|
|
2176
2416
|
children: filename
|
|
2177
2417
|
})
|
|
2178
2418
|
]
|
|
2179
2419
|
}),
|
|
2180
|
-
/* @__PURE__ */
|
|
2420
|
+
/* @__PURE__ */ jsxs27("div", {
|
|
2181
2421
|
className: "flex items-center gap-2 text-sm shrink-0 ml-2",
|
|
2182
2422
|
children: [
|
|
2183
|
-
hasAdditions && /* @__PURE__ */
|
|
2423
|
+
hasAdditions && /* @__PURE__ */ jsxs27("span", {
|
|
2184
2424
|
className: "text-green-500 font-medium",
|
|
2185
2425
|
children: [
|
|
2186
2426
|
"+",
|
|
2187
2427
|
diff2.additions
|
|
2188
2428
|
]
|
|
2189
2429
|
}),
|
|
2190
|
-
hasDeletions && /* @__PURE__ */
|
|
2430
|
+
hasDeletions && /* @__PURE__ */ jsxs27("span", {
|
|
2191
2431
|
className: "text-red-500 font-medium",
|
|
2192
2432
|
children: [
|
|
2193
2433
|
"-",
|
|
@@ -2196,24 +2436,24 @@ function ClientDiffCode(props) {
|
|
|
2196
2436
|
})
|
|
2197
2437
|
]
|
|
2198
2438
|
}),
|
|
2199
|
-
/* @__PURE__ */
|
|
2439
|
+
/* @__PURE__ */ jsx45(StackedChevrons, {
|
|
2200
2440
|
isOpen,
|
|
2201
2441
|
className: "ml-2"
|
|
2202
2442
|
})
|
|
2203
2443
|
]
|
|
2204
2444
|
})
|
|
2205
2445
|
}),
|
|
2206
|
-
/* @__PURE__ */
|
|
2207
|
-
children: /* @__PURE__ */
|
|
2446
|
+
/* @__PURE__ */ jsx45(CollapsibleContent2, {
|
|
2447
|
+
children: /* @__PURE__ */ jsxs27("div", {
|
|
2208
2448
|
className: "relative flex items-start",
|
|
2209
2449
|
children: [
|
|
2210
|
-
/* @__PURE__ */
|
|
2450
|
+
/* @__PURE__ */ jsx45(Pre3, {
|
|
2211
2451
|
code: highlighted,
|
|
2212
2452
|
className: "overflow-auto px-0 py-3 m-0 rounded-none !bg-openpkg-code-bg selection:bg-openpkg-code-selection selection:text-current max-h-full flex-1",
|
|
2213
2453
|
style: highlightedStyle,
|
|
2214
2454
|
handlers
|
|
2215
2455
|
}),
|
|
2216
|
-
showCopy && /* @__PURE__ */
|
|
2456
|
+
showCopy && /* @__PURE__ */ jsx45(CopyButton, {
|
|
2217
2457
|
text: highlighted.code,
|
|
2218
2458
|
variant: "floating",
|
|
2219
2459
|
className: "absolute right-3 top-3 z-10 text-openpkg-code-text-inactive"
|
|
@@ -2233,19 +2473,19 @@ function extractFlags3(codeblock) {
|
|
|
2233
2473
|
return { title, flags: flags.slice(1) };
|
|
2234
2474
|
}
|
|
2235
2475
|
// src/docskit/code.inline.tsx
|
|
2236
|
-
import { highlight as
|
|
2237
|
-
import { jsx as
|
|
2476
|
+
import { highlight as highlight4, Inline as Inline2 } from "codehike/code";
|
|
2477
|
+
import { jsx as jsx46 } from "react/jsx-runtime";
|
|
2238
2478
|
async function DocsKitInlineCode({ codeblock }) {
|
|
2239
|
-
const highlighted = await
|
|
2240
|
-
return /* @__PURE__ */
|
|
2479
|
+
const highlighted = await highlight4(codeblock, theme);
|
|
2480
|
+
return /* @__PURE__ */ jsx46(Inline2, {
|
|
2241
2481
|
code: highlighted,
|
|
2242
2482
|
className: "selection:bg-openpkg-code-selection selection:text-current rounded border border-openpkg-code-border px-1 py-0.5 whitespace-nowrap !bg-openpkg-code-bg",
|
|
2243
2483
|
style: highlighted.style
|
|
2244
2484
|
});
|
|
2245
2485
|
}
|
|
2246
2486
|
// src/docskit/code.package-install.tsx
|
|
2247
|
-
import { useState as
|
|
2248
|
-
import { jsx as
|
|
2487
|
+
import { useState as useState14 } from "react";
|
|
2488
|
+
import { jsx as jsx47, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
2249
2489
|
|
|
2250
2490
|
var managerLabels = {
|
|
2251
2491
|
npm: "npm",
|
|
@@ -2297,81 +2537,61 @@ function PackageInstall({
|
|
|
2297
2537
|
managers = ["npm", "bun", "pnpm", "yarn"],
|
|
2298
2538
|
copyButton = true
|
|
2299
2539
|
}) {
|
|
2300
|
-
const [activeManager, setActiveManager] =
|
|
2540
|
+
const [activeManager, setActiveManager] = useState14(managers[0]);
|
|
2301
2541
|
const command = getInstallCommand(activeManager, pkg, { dev, global: isGlobal });
|
|
2302
|
-
return /* @__PURE__ */
|
|
2542
|
+
return /* @__PURE__ */ jsxs28("div", {
|
|
2303
2543
|
className: "group rounded overflow-hidden border border-openpkg-code-border flex flex-col my-4 not-prose",
|
|
2304
2544
|
children: [
|
|
2305
|
-
/* @__PURE__ */
|
|
2545
|
+
/* @__PURE__ */ jsxs28("div", {
|
|
2306
2546
|
className: cn("border-b border-openpkg-code-border bg-openpkg-code-header", "w-full h-9 flex items-center px-3 gap-2 shrink-0"),
|
|
2307
2547
|
children: [
|
|
2308
|
-
/* @__PURE__ */
|
|
2548
|
+
/* @__PURE__ */ jsxs28("div", {
|
|
2309
2549
|
className: "flex items-center gap-2",
|
|
2310
2550
|
children: [
|
|
2311
|
-
/* @__PURE__ */
|
|
2551
|
+
/* @__PURE__ */ jsx47("div", {
|
|
2312
2552
|
className: "size-3 rounded-full bg-openpkg-code-text-inactive/30"
|
|
2313
2553
|
}),
|
|
2314
|
-
/* @__PURE__ */
|
|
2554
|
+
/* @__PURE__ */ jsx47("div", {
|
|
2315
2555
|
className: "size-3 rounded-full bg-openpkg-code-text-inactive/30"
|
|
2316
2556
|
}),
|
|
2317
|
-
/* @__PURE__ */
|
|
2557
|
+
/* @__PURE__ */ jsx47("div", {
|
|
2318
2558
|
className: "size-3 rounded-full bg-openpkg-code-text-inactive/30"
|
|
2319
2559
|
})
|
|
2320
2560
|
]
|
|
2321
2561
|
}),
|
|
2322
|
-
/* @__PURE__ */
|
|
2562
|
+
/* @__PURE__ */ jsx47("div", {
|
|
2323
2563
|
className: "flex items-center gap-0.5 ml-1",
|
|
2324
|
-
children: managers.map((manager) => /* @__PURE__ */
|
|
2564
|
+
children: managers.map((manager) => /* @__PURE__ */ jsx47("button", {
|
|
2325
2565
|
type: "button",
|
|
2326
2566
|
onClick: () => setActiveManager(manager),
|
|
2327
2567
|
className: cn("px-2 py-0.5 text-sm font-medium rounded-md transition-colors duration-200", "border h-6", activeManager === manager ? "bg-openpkg-code-bg border-openpkg-code-border text-openpkg-code-text-active" : "border-transparent text-openpkg-code-text-inactive hover:text-openpkg-code-text-active"),
|
|
2328
2568
|
children: managerLabels[manager]
|
|
2329
2569
|
}, manager))
|
|
2330
2570
|
}),
|
|
2331
|
-
/* @__PURE__ */
|
|
2571
|
+
/* @__PURE__ */ jsx47("span", {
|
|
2332
2572
|
className: "sr-only",
|
|
2333
2573
|
children: "Terminal window"
|
|
2334
2574
|
})
|
|
2335
2575
|
]
|
|
2336
2576
|
}),
|
|
2337
|
-
/* @__PURE__ */
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
/* @__PURE__ */ jsx36("span", {
|
|
2345
|
-
className: "text-ch-5",
|
|
2346
|
-
children: command.split(" ")[0]
|
|
2347
|
-
}),
|
|
2348
|
-
/* @__PURE__ */ jsxs21("span", {
|
|
2349
|
-
className: "text-ch-0",
|
|
2350
|
-
children: [
|
|
2351
|
-
" ",
|
|
2352
|
-
command.split(" ").slice(1).join(" ")
|
|
2353
|
-
]
|
|
2354
|
-
})
|
|
2355
|
-
]
|
|
2356
|
-
})
|
|
2357
|
-
}),
|
|
2358
|
-
copyButton && /* @__PURE__ */ jsx36(CopyButton, {
|
|
2359
|
-
text: command,
|
|
2360
|
-
variant: "floating",
|
|
2361
|
-
className: "absolute right-3 top-1/2 -translate-y-1/2 z-10 text-openpkg-code-text-inactive"
|
|
2362
|
-
})
|
|
2363
|
-
]
|
|
2577
|
+
/* @__PURE__ */ jsx47(ClientDocsKitCode, {
|
|
2578
|
+
codeblock: {
|
|
2579
|
+
value: command,
|
|
2580
|
+
lang: "bash",
|
|
2581
|
+
meta: copyButton ? "-c" : ""
|
|
2582
|
+
},
|
|
2583
|
+
className: "!my-0 !border-0 !rounded-none"
|
|
2364
2584
|
})
|
|
2365
2585
|
]
|
|
2366
2586
|
});
|
|
2367
2587
|
}
|
|
2368
2588
|
// src/docskit/code.tabs.tsx
|
|
2369
|
-
import { Block, CodeBlock } from "codehike/blocks";
|
|
2589
|
+
import { Block, CodeBlock as CodeBlock2 } from "codehike/blocks";
|
|
2370
2590
|
import { z } from "zod";
|
|
2371
|
-
import { jsx as
|
|
2591
|
+
import { jsx as jsx48 } from "react/jsx-runtime";
|
|
2372
2592
|
async function CodeGroup(props) {
|
|
2373
2593
|
const result = Block.extend({
|
|
2374
|
-
code: z.array(
|
|
2594
|
+
code: z.array(CodeBlock2),
|
|
2375
2595
|
flags: z.string().optional(),
|
|
2376
2596
|
storage: z.string().optional(),
|
|
2377
2597
|
handlers: z.array(z.any()).optional()
|
|
@@ -2380,16 +2600,16 @@ async function CodeGroup(props) {
|
|
|
2380
2600
|
throw betterError(result.error, "CodeGroup");
|
|
2381
2601
|
}
|
|
2382
2602
|
const { code, ...rest } = result.data;
|
|
2383
|
-
return /* @__PURE__ */
|
|
2603
|
+
return /* @__PURE__ */ jsx48(Code, {
|
|
2384
2604
|
codeblocks: code,
|
|
2385
2605
|
...rest
|
|
2386
2606
|
});
|
|
2387
2607
|
}
|
|
2388
2608
|
async function Code(props) {
|
|
2389
2609
|
const group = await toCodeGroup(props);
|
|
2390
|
-
return group.tabs.length === 1 ? /* @__PURE__ */
|
|
2610
|
+
return group.tabs.length === 1 ? /* @__PURE__ */ jsx48(SingleCode, {
|
|
2391
2611
|
group
|
|
2392
|
-
}) : /* @__PURE__ */
|
|
2612
|
+
}) : /* @__PURE__ */ jsx48(MultiCode, {
|
|
2393
2613
|
group
|
|
2394
2614
|
}, group.storage);
|
|
2395
2615
|
}
|
|
@@ -2402,13 +2622,13 @@ function betterError(error, componentName) {
|
|
|
2402
2622
|
}
|
|
2403
2623
|
}
|
|
2404
2624
|
// src/docskit/code.terminal.tsx
|
|
2405
|
-
import { highlight as
|
|
2406
|
-
import { jsx as
|
|
2625
|
+
import { highlight as highlight5, Pre as Pre4 } from "codehike/code";
|
|
2626
|
+
import { jsx as jsx49, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
2407
2627
|
async function Terminal(props) {
|
|
2408
2628
|
const { codeblock, handlers: extraHandlers } = props;
|
|
2409
2629
|
const { flags } = extractFlags4(codeblock);
|
|
2410
2630
|
const options = flagsToOptions(flags);
|
|
2411
|
-
const highlighted = await
|
|
2631
|
+
const highlighted = await highlight5({ ...codeblock, lang: codeblock.lang || "bash" }, theme);
|
|
2412
2632
|
const handlers = getHandlers(options);
|
|
2413
2633
|
if (extraHandlers) {
|
|
2414
2634
|
handlers.push(...extraHandlers);
|
|
@@ -2417,42 +2637,42 @@ async function Terminal(props) {
|
|
|
2417
2637
|
const showCopy = options?.copyButton;
|
|
2418
2638
|
const isMultiLine = highlighted.code.includes(`
|
|
2419
2639
|
`);
|
|
2420
|
-
return /* @__PURE__ */
|
|
2640
|
+
return /* @__PURE__ */ jsxs29("div", {
|
|
2421
2641
|
className: "group rounded overflow-hidden relative border-openpkg-code-border flex flex-col border my-4 not-prose",
|
|
2422
2642
|
children: [
|
|
2423
|
-
/* @__PURE__ */
|
|
2643
|
+
/* @__PURE__ */ jsxs29("div", {
|
|
2424
2644
|
className: cn("border-b border-openpkg-code-border bg-openpkg-code-header", "w-full h-9 flex items-center justify-center shrink-0", "relative"),
|
|
2425
2645
|
children: [
|
|
2426
|
-
/* @__PURE__ */
|
|
2646
|
+
/* @__PURE__ */ jsxs29("div", {
|
|
2427
2647
|
className: "absolute left-3 flex items-center gap-2",
|
|
2428
2648
|
children: [
|
|
2429
|
-
/* @__PURE__ */
|
|
2649
|
+
/* @__PURE__ */ jsx49("div", {
|
|
2430
2650
|
className: "size-3 rounded-full bg-openpkg-code-text-inactive/30"
|
|
2431
2651
|
}),
|
|
2432
|
-
/* @__PURE__ */
|
|
2652
|
+
/* @__PURE__ */ jsx49("div", {
|
|
2433
2653
|
className: "size-3 rounded-full bg-openpkg-code-text-inactive/30"
|
|
2434
2654
|
}),
|
|
2435
|
-
/* @__PURE__ */
|
|
2655
|
+
/* @__PURE__ */ jsx49("div", {
|
|
2436
2656
|
className: "size-3 rounded-full bg-openpkg-code-text-inactive/30"
|
|
2437
2657
|
})
|
|
2438
2658
|
]
|
|
2439
2659
|
}),
|
|
2440
|
-
/* @__PURE__ */
|
|
2660
|
+
/* @__PURE__ */ jsx49("span", {
|
|
2441
2661
|
className: "sr-only",
|
|
2442
2662
|
children: "Terminal window"
|
|
2443
2663
|
})
|
|
2444
2664
|
]
|
|
2445
2665
|
}),
|
|
2446
|
-
/* @__PURE__ */
|
|
2666
|
+
/* @__PURE__ */ jsxs29("div", {
|
|
2447
2667
|
className: "relative flex items-start",
|
|
2448
2668
|
children: [
|
|
2449
|
-
/* @__PURE__ */
|
|
2669
|
+
/* @__PURE__ */ jsx49(Pre4, {
|
|
2450
2670
|
code: highlighted,
|
|
2451
2671
|
className: "overflow-auto px-0 py-3 m-0 rounded-none !bg-openpkg-code-bg selection:bg-openpkg-code-selection selection:text-current max-h-full flex-1",
|
|
2452
2672
|
style: highlightedStyle,
|
|
2453
2673
|
handlers
|
|
2454
2674
|
}),
|
|
2455
|
-
showCopy && /* @__PURE__ */
|
|
2675
|
+
showCopy && /* @__PURE__ */ jsx49(CopyButton, {
|
|
2456
2676
|
text: highlighted.code,
|
|
2457
2677
|
variant: "floating",
|
|
2458
2678
|
className: cn("absolute right-3 z-10 text-openpkg-code-text-inactive", isMultiLine ? "top-3" : "top-1/2 -translate-y-1/2")
|
|
@@ -2469,19 +2689,19 @@ function extractFlags4(codeblock) {
|
|
|
2469
2689
|
return { flags };
|
|
2470
2690
|
}
|
|
2471
2691
|
// src/docskit/docskit.tsx
|
|
2472
|
-
import
|
|
2692
|
+
import React7 from "react";
|
|
2473
2693
|
function addDocsKit(components) {
|
|
2474
2694
|
return {
|
|
2475
2695
|
...components,
|
|
2476
2696
|
DocsKitCode,
|
|
2477
2697
|
DocsKitInlineCode,
|
|
2478
2698
|
a: (props) => {
|
|
2479
|
-
return
|
|
2699
|
+
return React7.createElement(components?.a || "a", props);
|
|
2480
2700
|
}
|
|
2481
2701
|
};
|
|
2482
2702
|
}
|
|
2483
2703
|
// src/docskit/notes.tsx
|
|
2484
|
-
import { jsx as
|
|
2704
|
+
import { jsx as jsx50 } from "react/jsx-runtime";
|
|
2485
2705
|
function WithNotes({ children, ...rest }) {
|
|
2486
2706
|
const notes = Object.entries(rest).filter(([name]) => name !== "title" && name !== "_data").map(([name, value]) => {
|
|
2487
2707
|
const block = value;
|
|
@@ -2495,7 +2715,7 @@ function WithNotes({ children, ...rest }) {
|
|
|
2495
2715
|
return {
|
|
2496
2716
|
name,
|
|
2497
2717
|
type: "code",
|
|
2498
|
-
children: /* @__PURE__ */
|
|
2718
|
+
children: /* @__PURE__ */ jsx50(Code, {
|
|
2499
2719
|
codeblocks: [block]
|
|
2500
2720
|
})
|
|
2501
2721
|
};
|
|
@@ -2503,7 +2723,7 @@ function WithNotes({ children, ...rest }) {
|
|
|
2503
2723
|
return {
|
|
2504
2724
|
name,
|
|
2505
2725
|
type: "image",
|
|
2506
|
-
children: /* @__PURE__ */
|
|
2726
|
+
children: /* @__PURE__ */ jsx50("img", {
|
|
2507
2727
|
src: block.url,
|
|
2508
2728
|
alt: block.alt
|
|
2509
2729
|
})
|
|
@@ -2512,21 +2732,21 @@ function WithNotes({ children, ...rest }) {
|
|
|
2512
2732
|
throw new Error("Invalid block inside <WithNotes />");
|
|
2513
2733
|
}
|
|
2514
2734
|
});
|
|
2515
|
-
return /* @__PURE__ */
|
|
2735
|
+
return /* @__PURE__ */ jsx50(WithClientNotes, {
|
|
2516
2736
|
notes,
|
|
2517
2737
|
children
|
|
2518
2738
|
});
|
|
2519
2739
|
}
|
|
2520
2740
|
// src/docskit/import-section.tsx
|
|
2521
|
-
import { Check as
|
|
2741
|
+
import { Check as Check4, Copy as Copy4 } from "lucide-react";
|
|
2522
2742
|
|
|
2523
2743
|
// src/hooks/use-copy-to-clipboard.ts
|
|
2524
|
-
import { useCallback, useRef as
|
|
2744
|
+
import { useCallback as useCallback2, useRef as useRef5, useState as useState15 } from "react";
|
|
2525
2745
|
var COPY_FEEDBACK_MS = 1200;
|
|
2526
2746
|
function useCopyToClipboard(timeout = COPY_FEEDBACK_MS) {
|
|
2527
|
-
const [copied, setCopied] =
|
|
2528
|
-
const timerRef =
|
|
2529
|
-
const copy =
|
|
2747
|
+
const [copied, setCopied] = useState15(false);
|
|
2748
|
+
const timerRef = useRef5(undefined);
|
|
2749
|
+
const copy = useCallback2((text) => {
|
|
2530
2750
|
navigator.clipboard.writeText(text).then(() => {
|
|
2531
2751
|
setCopied(true);
|
|
2532
2752
|
clearTimeout(timerRef.current);
|
|
@@ -2537,28 +2757,28 @@ function useCopyToClipboard(timeout = COPY_FEEDBACK_MS) {
|
|
|
2537
2757
|
}
|
|
2538
2758
|
|
|
2539
2759
|
// src/docskit/import-section.tsx
|
|
2540
|
-
import { jsx as
|
|
2760
|
+
import { jsx as jsx51, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
2541
2761
|
|
|
2542
2762
|
function ImportSection({ importStatement, className }) {
|
|
2543
2763
|
const [copied, copy] = useCopyToClipboard();
|
|
2544
2764
|
const handleCopy = () => {
|
|
2545
2765
|
copy(importStatement);
|
|
2546
2766
|
};
|
|
2547
|
-
return /* @__PURE__ */
|
|
2767
|
+
return /* @__PURE__ */ jsxs30("div", {
|
|
2548
2768
|
className: cn("group flex items-center justify-between gap-3", "rounded-lg border border-[var(--openpkg-border-subtle)] bg-[var(--openpkg-bg-secondary)] px-4 py-3", className),
|
|
2549
2769
|
children: [
|
|
2550
|
-
/* @__PURE__ */
|
|
2770
|
+
/* @__PURE__ */ jsx51("code", {
|
|
2551
2771
|
className: "font-mono text-sm text-[var(--openpkg-text-primary)] overflow-x-auto",
|
|
2552
2772
|
children: importStatement
|
|
2553
2773
|
}),
|
|
2554
|
-
/* @__PURE__ */
|
|
2774
|
+
/* @__PURE__ */ jsx51("button", {
|
|
2555
2775
|
type: "button",
|
|
2556
2776
|
onClick: handleCopy,
|
|
2557
2777
|
className: cn("shrink-0 p-1.5 rounded", "text-[var(--openpkg-text-muted)] hover:text-[var(--openpkg-text-primary)]", "opacity-0 group-hover:opacity-100 transition-opacity duration-200", "cursor-pointer"),
|
|
2558
2778
|
"aria-label": "Copy import statement",
|
|
2559
|
-
children: copied ? /* @__PURE__ */
|
|
2779
|
+
children: copied ? /* @__PURE__ */ jsx51(Check4, {
|
|
2560
2780
|
size: 16
|
|
2561
|
-
}) : /* @__PURE__ */
|
|
2781
|
+
}) : /* @__PURE__ */ jsx51(Copy4, {
|
|
2562
2782
|
size: 16
|
|
2563
2783
|
})
|
|
2564
2784
|
})
|
|
@@ -2567,8 +2787,8 @@ function ImportSection({ importStatement, className }) {
|
|
|
2567
2787
|
}
|
|
2568
2788
|
// src/docskit/type-badge.tsx
|
|
2569
2789
|
import { cva as cva2 } from "class-variance-authority";
|
|
2570
|
-
import * as
|
|
2571
|
-
import { jsx as
|
|
2790
|
+
import * as React8 from "react";
|
|
2791
|
+
import { jsx as jsx52 } from "react/jsx-runtime";
|
|
2572
2792
|
var typeBadgeVariants = cva2("font-mono text-sm", {
|
|
2573
2793
|
variants: {
|
|
2574
2794
|
typeColor: {
|
|
@@ -2623,9 +2843,9 @@ function detectTypeColor(type) {
|
|
|
2623
2843
|
}
|
|
2624
2844
|
return "default";
|
|
2625
2845
|
}
|
|
2626
|
-
var TypeBadge =
|
|
2846
|
+
var TypeBadge = React8.forwardRef(({ className, type, typeColor, ...props }, ref) => {
|
|
2627
2847
|
const color2 = typeColor ?? detectTypeColor(type);
|
|
2628
|
-
return /* @__PURE__ */
|
|
2848
|
+
return /* @__PURE__ */ jsx52("span", {
|
|
2629
2849
|
ref,
|
|
2630
2850
|
className: cn(typeBadgeVariants({ typeColor: color2 }), className),
|
|
2631
2851
|
...props,
|
|
@@ -2635,6 +2855,8 @@ var TypeBadge = React9.forwardRef(({ className, type, typeColor, ...props }, ref
|
|
|
2635
2855
|
TypeBadge.displayName = "TypeBadge";
|
|
2636
2856
|
export {
|
|
2637
2857
|
wordWrap,
|
|
2858
|
+
useSyncSection,
|
|
2859
|
+
useSyncScroll,
|
|
2638
2860
|
typeBadgeVariants,
|
|
2639
2861
|
tooltip,
|
|
2640
2862
|
toCodeGroup,
|
|
@@ -2660,24 +2882,34 @@ export {
|
|
|
2660
2882
|
TabsList,
|
|
2661
2883
|
TabsContent,
|
|
2662
2884
|
Tabs,
|
|
2885
|
+
SyncScrollProvider,
|
|
2663
2886
|
SingleCode,
|
|
2664
2887
|
ResponseBlock,
|
|
2665
2888
|
ParameterList,
|
|
2666
2889
|
PackageInstall,
|
|
2890
|
+
NestedParameterToggle,
|
|
2891
|
+
NestedParameterContainer,
|
|
2667
2892
|
MultiCode,
|
|
2893
|
+
MethodSection,
|
|
2668
2894
|
LanguageSelector,
|
|
2669
2895
|
InlineCodeSkeleton,
|
|
2670
2896
|
ImportSection,
|
|
2671
2897
|
HoverLink,
|
|
2898
|
+
ExpandableParameter,
|
|
2899
|
+
ExampleSection,
|
|
2900
|
+
ExampleChips,
|
|
2901
|
+
EnumValuesSection,
|
|
2672
2902
|
EndpointHeader,
|
|
2673
2903
|
EndpointBadge,
|
|
2674
2904
|
DocsKitInlineCode,
|
|
2675
2905
|
DocsKitCode,
|
|
2676
2906
|
CopyButton,
|
|
2907
|
+
CollapsiblePanel,
|
|
2677
2908
|
CodeTabsSkeleton,
|
|
2678
2909
|
CodeIcon,
|
|
2679
2910
|
CodeGroup,
|
|
2680
2911
|
CodeBlockSkeleton,
|
|
2912
|
+
CodeBlock,
|
|
2681
2913
|
Code,
|
|
2682
2914
|
ClientTerminal,
|
|
2683
2915
|
ClientInlineCode,
|
|
@@ -2686,6 +2918,7 @@ export {
|
|
|
2686
2918
|
ClientCode,
|
|
2687
2919
|
APISection,
|
|
2688
2920
|
APIReferencePage,
|
|
2921
|
+
APIReferenceLayout,
|
|
2689
2922
|
APIParameterItem,
|
|
2690
2923
|
APICodePanel
|
|
2691
2924
|
};
|