fumadocs-openapi 11.4.3 → 12.0.1
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/css/generated/shared.css +1 -1
- package/css/preset.css +0 -1
- package/dist/_virtual/_rolldown/runtime.js +10 -1
- package/dist/generate-file.d.ts +2 -2
- package/dist/generate-file.js +1 -1
- package/dist/i18n.d.ts +6 -8
- package/dist/i18n.js +2 -17
- package/dist/index.browser.d.ts +13 -0
- package/dist/index.browser.js +11 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +3 -1
- package/dist/operation.d.ts +133 -0
- package/dist/operation.js +296 -0
- package/dist/packages/shared-api/dist/.translations/index.d.ts +29 -0
- package/dist/packages/shared-api/dist/.translations/keys.js +28 -0
- package/dist/packages/shared-api/dist/auto-anchor/client.js +20 -0
- package/dist/packages/shared-api/dist/auto-anchor/index.js +17 -0
- package/dist/packages/shared-api/dist/codegen.d.ts +42 -0
- package/dist/packages/shared-api/dist/codegen.js +35 -0
- package/dist/packages/shared-api/dist/components/accordion.js +71 -0
- package/dist/packages/shared-api/dist/components/badge.js +21 -0
- package/dist/packages/shared-api/dist/components/collapsible.d.ts +7 -0
- package/dist/packages/shared-api/dist/components/collapsible.js +16 -0
- package/dist/packages/shared-api/dist/components/defaults.d.ts +20 -0
- package/dist/packages/shared-api/dist/components/defaults.js +70 -0
- package/dist/packages/shared-api/dist/components/dialog.js +55 -0
- package/dist/packages/shared-api/dist/components/input.js +14 -0
- package/dist/packages/shared-api/dist/components/label.js +11 -0
- package/dist/packages/shared-api/dist/components/playground/inputs.js +439 -0
- package/dist/packages/shared-api/dist/components/playground/schema.js +112 -0
- package/dist/packages/shared-api/dist/components/popover.js +23 -0
- package/dist/packages/shared-api/dist/components/schema/client.d.ts +12 -0
- package/dist/packages/shared-api/dist/components/schema/client.js +508 -0
- package/dist/packages/shared-api/dist/components/schema/index.d.ts +9 -0
- package/dist/packages/shared-api/dist/components/schema/index.js +28 -0
- package/dist/packages/shared-api/dist/components/select-tab.js +54 -0
- package/dist/packages/shared-api/dist/components/select.js +70 -0
- package/dist/packages/shared-api/dist/components/spinner.js +14 -0
- package/dist/packages/shared-api/dist/i18n.d.ts +3 -0
- package/dist/packages/shared-api/dist/i18n.js +7 -0
- package/dist/packages/shared-api/dist/utils/cn.js +2 -0
- package/dist/packages/shared-api/dist/utils/id-to-title.js +12 -0
- package/dist/packages/shared-api/dist/utils/is-plain-object.js +8 -0
- package/dist/packages/shared-api/dist/utils/merge-refs.js +11 -0
- package/dist/packages/shared-api/dist/utils/url.js +13 -0
- package/dist/{utils → packages/shared-api/dist/utils}/use-query.js +2 -1
- package/dist/packages/shared-api/dist/utils/use-server-store.js +56 -0
- package/dist/playground/auth.d.ts +85 -0
- package/dist/playground/auth.js +216 -21
- package/dist/playground/fetcher.d.ts +11 -1
- package/dist/playground/index.d.ts +3 -0
- package/dist/playground/index.js +3 -0
- package/dist/requests/generators/index.d.ts +4 -4
- package/dist/requests/generators/index.js +2 -2
- package/dist/requests/index.d.ts +4 -0
- package/dist/requests/index.js +3 -0
- package/dist/requests/media/adapter.d.ts +1 -0
- package/dist/requests/media/encode.d.ts +7 -2
- package/dist/requests/media/resolve-adapter.d.ts +20 -0
- package/dist/server/index.d.ts +4 -7
- package/dist/server/index.js +2 -8
- package/dist/types.d.ts +0 -14
- package/dist/ui/base.d.ts +3 -2
- package/dist/ui/base.js +15 -166
- package/dist/ui/components/codeblock.js +3 -10
- package/dist/ui/components/heading.js +10 -19
- package/dist/ui/components/markdown.js +4 -6
- package/dist/ui/components/method-label.js +2 -17
- package/dist/ui/components/schema.js +28 -0
- package/dist/ui/index.d.ts +7 -198
- package/dist/ui/index.js +1 -3
- package/dist/ui/operation/index.js +142 -229
- package/dist/ui/operation/request-tabs.js +15 -23
- package/dist/ui/operation/response-tabs.js +9 -53
- package/dist/ui/operation/usage-tabs.js +35 -93
- package/dist/{playground → ui/playground}/client.d.ts +10 -21
- package/dist/ui/playground/client.js +432 -0
- package/dist/{playground → ui/playground}/components/oauth-dialog.js +26 -91
- package/dist/{playground → ui/playground}/components/result-display.d.ts +2 -2
- package/dist/{playground → ui/playground}/components/result-display.js +7 -7
- package/dist/{playground → ui/playground}/components/server-select.js +12 -13
- package/dist/{playground → ui/playground}/status-info.js +2 -2
- package/dist/{scalar → ui/scalar}/client.js +7 -5
- package/dist/{scalar → ui/scalar}/index.d.ts +2 -2
- package/dist/{scalar → ui/scalar}/index.js +3 -7
- package/dist/utils/create-page.d.ts +216 -0
- package/dist/utils/create-page.js +221 -0
- package/dist/utils/document/dereference.d.ts +2 -2
- package/dist/utils/document/dereference.js +8 -3
- package/dist/utils/document/load.js +2 -2
- package/dist/utils/get-example-requests.js +11 -13
- package/dist/utils/pages/builder.d.ts +15 -2
- package/dist/utils/pages/builder.js +6 -6
- package/dist/utils/pages/preset-auto.d.ts +1 -1
- package/dist/utils/pages/preset-auto.js +3 -3
- package/dist/utils/pages/to-static-data.js +4 -4
- package/dist/utils/pages/to-text.d.ts +1 -1
- package/dist/utils/pages/to-text.js +3 -5
- package/dist/utils/schema.js +5 -5
- package/dist/utils/use-server.d.ts +24 -0
- package/dist/utils/use-server.js +57 -0
- package/package.json +29 -21
- package/dist/node_modules/.pnpm/@scalar_openapi-upgrader@0.2.15/node_modules/@scalar/openapi-upgrader/dist/2.0-to-3.0/upgrade-from-two-to-three.js +0 -508
- package/dist/node_modules/.pnpm/@scalar_openapi-upgrader@0.2.15/node_modules/@scalar/openapi-upgrader/dist/3.0-to-3.1/upgrade-from-three-to-three-one.js +0 -152
- package/dist/node_modules/.pnpm/@scalar_openapi-upgrader@0.2.15/node_modules/@scalar/openapi-upgrader/dist/3.1-to-3.2/upgrade-from-three-one-to-three-two.js +0 -61
- package/dist/node_modules/.pnpm/@scalar_openapi-upgrader@0.2.15/node_modules/@scalar/openapi-upgrader/dist/helpers/traverse.js +0 -25
- package/dist/node_modules/.pnpm/@scalar_openapi-upgrader@0.2.15/node_modules/@scalar/openapi-upgrader/dist/upgrade.js +0 -15
- package/dist/playground/client.js +0 -574
- package/dist/ui/contexts/api.d.ts +0 -17
- package/dist/ui/contexts/api.js +0 -84
- package/dist/ui/create-client.d.ts +0 -9
- package/dist/ui/create-client.js +0 -7
- package/dist/ui/operation/context.d.ts +0 -15
- package/dist/ui/operation/context.js +0 -48
- package/dist/ui/operation/request-tabs.d.ts +0 -12
- package/dist/ui/operation/response-tabs.d.ts +0 -30
- package/dist/utils/get-example-requests.d.ts +0 -11
- package/dist/utils/schema.d.ts +0 -3
- package/dist/utils/storage-key.js +0 -15
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region ../shared-api/dist/.translations/keys.js
|
|
2
|
+
var keys_default = [
|
|
3
|
+
"Default(schema UI)",
|
|
4
|
+
"Deprecated(schema UI)",
|
|
5
|
+
"Enter Property Name(playground)",
|
|
6
|
+
"Enter value(playground)",
|
|
7
|
+
"Example(schema UI)",
|
|
8
|
+
"Filter Properties(schema UI)",
|
|
9
|
+
"Format(schema UI)",
|
|
10
|
+
"Items(schema UI)",
|
|
11
|
+
"Length(schema UI)",
|
|
12
|
+
"Match(schema UI)",
|
|
13
|
+
"Multiple Of(schema UI)",
|
|
14
|
+
"New Item(playground)",
|
|
15
|
+
"New(playground)",
|
|
16
|
+
"No property matching(schema UI)",
|
|
17
|
+
"Properties(schema UI)",
|
|
18
|
+
"Range(schema UI)",
|
|
19
|
+
"Remove Item(playground)(aria-label)",
|
|
20
|
+
"Select(playground)",
|
|
21
|
+
"Selected(playground)",
|
|
22
|
+
"Show Property(playground)",
|
|
23
|
+
"Unset(playground)",
|
|
24
|
+
"Upload(playground)",
|
|
25
|
+
"Value in(schema UI)"
|
|
26
|
+
];
|
|
27
|
+
//#endregion
|
|
28
|
+
export { keys_default as default };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { anchorSegments } from "./index.js";
|
|
3
|
+
import { createContext, use, useMemo } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region ../shared-api/dist/auto-anchor/client.js
|
|
6
|
+
const AnchorContext = createContext([]);
|
|
7
|
+
/** Append segment to anchor IDs */
|
|
8
|
+
function AnchorSection({ segments, children }) {
|
|
9
|
+
const v = use(AnchorContext);
|
|
10
|
+
return /* @__PURE__ */ jsx(AnchorContext, {
|
|
11
|
+
value: useMemo(() => [...v, ...segments], [v, segments]),
|
|
12
|
+
children
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function useAnchorId(segments) {
|
|
16
|
+
if (!segments) return null;
|
|
17
|
+
return anchorSegments(...use(AnchorContext), ...segments);
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { AnchorSection, useAnchorId };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { slug } from "github-slugger";
|
|
2
|
+
//#region ../shared-api/dist/auto-anchor/index.js
|
|
3
|
+
/** slugify segments, append `\0` to keep segment as-is */
|
|
4
|
+
function anchorSegments(...segs) {
|
|
5
|
+
const mapped = [];
|
|
6
|
+
for (const seg of segs) if (seg.startsWith("\0")) mapped.push(seg.slice(1));
|
|
7
|
+
else if (seg.length > 0) mapped.push(slug(seg));
|
|
8
|
+
return mapped.join(".");
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Check if `id1` starts with `id2`
|
|
12
|
+
*/
|
|
13
|
+
function anchorIdStartsWith(id1, id2) {
|
|
14
|
+
return id1 === id2 || id1.startsWith(`${id2}.`);
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { anchorIdStartsWith, anchorSegments };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
declare namespace codegen_d_exports {
|
|
2
|
+
export { CodeUsageGenerator, CodeUsageGeneratorRegistry, InlineCodeUsageGenerator, createCodeUsageGeneratorRegistry };
|
|
3
|
+
}
|
|
4
|
+
//#region src/codegen.d.ts
|
|
5
|
+
export interface CodeUsageGeneratorRegistry<Data = unknown, Context = unknown> {
|
|
6
|
+
add: (id: string, generator: CodeUsageGenerator<Data, Context>) => void;
|
|
7
|
+
get: (id: string) => CodeUsageGenerator<Data, Context> | undefined;
|
|
8
|
+
addInline: (generator: InlineCodeUsageGenerator<Data, Context>) => void;
|
|
9
|
+
/**
|
|
10
|
+
* @returns if the generator is removed
|
|
11
|
+
*/
|
|
12
|
+
remove: (id: string) => boolean;
|
|
13
|
+
map: () => Map<string, CodeUsageGenerator<Data, Context>>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Generate code example for given programming language
|
|
17
|
+
*/
|
|
18
|
+
export interface CodeUsageGenerator<Data = unknown, Context = unknown> {
|
|
19
|
+
generate: (data: Data, context: Context) => string;
|
|
20
|
+
lang: string;
|
|
21
|
+
label?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Generate code example for given programming language
|
|
25
|
+
*/
|
|
26
|
+
export interface InlineCodeUsageGenerator<Data = unknown, Context = unknown> {
|
|
27
|
+
id?: string;
|
|
28
|
+
lang: string;
|
|
29
|
+
label?: string;
|
|
30
|
+
/**
|
|
31
|
+
* either:
|
|
32
|
+
* - code
|
|
33
|
+
* - a function imported from a file with "use client" directive
|
|
34
|
+
* - false (disabled)
|
|
35
|
+
*/
|
|
36
|
+
source?: string | CodeUsageGeneratorFn<Data, Context> | false;
|
|
37
|
+
}
|
|
38
|
+
export declare function createCodeUsageGeneratorRegistry<Data, Context>(inherit?: CodeUsageGeneratorRegistry<Data, Context>): CodeUsageGeneratorRegistry<Data, Context>;
|
|
39
|
+
type CodeUsageGeneratorFn<Data, Context> = (data: Data, context: Context) => string;
|
|
40
|
+
//#endregion
|
|
41
|
+
//#endregion
|
|
42
|
+
export { codegen_d_exports };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region ../shared-api/dist/codegen.js
|
|
2
|
+
function createCodeUsageGeneratorRegistry(inherit) {
|
|
3
|
+
const registry = new Map(inherit?.map());
|
|
4
|
+
return {
|
|
5
|
+
add(id, generator) {
|
|
6
|
+
registry.set(id, generator);
|
|
7
|
+
},
|
|
8
|
+
get(id) {
|
|
9
|
+
return registry.get(id);
|
|
10
|
+
},
|
|
11
|
+
addInline(generator) {
|
|
12
|
+
const source = generator.source;
|
|
13
|
+
const id = generator.id ?? generator.lang;
|
|
14
|
+
if (!source) {
|
|
15
|
+
this.remove(id);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
registry.set(id, {
|
|
19
|
+
lang: generator.lang,
|
|
20
|
+
label: generator.label,
|
|
21
|
+
generate() {
|
|
22
|
+
return typeof source === "string" ? source : "";
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
remove(id) {
|
|
27
|
+
return registry.delete(id);
|
|
28
|
+
},
|
|
29
|
+
map() {
|
|
30
|
+
return registry;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { createCodeUsageGeneratorRegistry };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../utils/cn.js";
|
|
3
|
+
import { anchorIdStartsWith } from "../auto-anchor/index.js";
|
|
4
|
+
import { AnchorSection, useAnchorId } from "../auto-anchor/client.js";
|
|
5
|
+
import { createContext, use, useEffect, useMemo, useState } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { ChevronRight } from "lucide-react";
|
|
8
|
+
import { Accordion } from "@base-ui/react/accordion";
|
|
9
|
+
//#region ../shared-api/dist/components/accordion.js
|
|
10
|
+
const Context = createContext(null);
|
|
11
|
+
function Accordions({ type = "single", defaultValue, ...props }) {
|
|
12
|
+
const [value, setValue] = useState(() => {
|
|
13
|
+
if (Array.isArray(defaultValue)) return defaultValue;
|
|
14
|
+
if (defaultValue) return [defaultValue];
|
|
15
|
+
return [];
|
|
16
|
+
});
|
|
17
|
+
return /* @__PURE__ */ jsx(Context, {
|
|
18
|
+
value: useMemo(() => ({
|
|
19
|
+
type,
|
|
20
|
+
setValue
|
|
21
|
+
}), [type]),
|
|
22
|
+
children: /* @__PURE__ */ jsx(Accordion.Root, {
|
|
23
|
+
multiple: type === "multiple",
|
|
24
|
+
value,
|
|
25
|
+
onValueChange: setValue,
|
|
26
|
+
...props
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function AccordionItem({ value, className, anchorSegments, ...props }) {
|
|
31
|
+
const ctx = use(Context);
|
|
32
|
+
const id = useAnchorId(anchorSegments ?? false);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (id && anchorIdStartsWith(window.location.hash.slice(1), id)) ctx.setValue([value]);
|
|
35
|
+
}, [
|
|
36
|
+
value,
|
|
37
|
+
id,
|
|
38
|
+
ctx
|
|
39
|
+
]);
|
|
40
|
+
const content = /* @__PURE__ */ jsx(Accordion.Item, {
|
|
41
|
+
value,
|
|
42
|
+
className: cn("scroll-m-20 border-b last:border-b-0", className),
|
|
43
|
+
...props
|
|
44
|
+
});
|
|
45
|
+
return anchorSegments ? /* @__PURE__ */ jsx(AnchorSection, {
|
|
46
|
+
segments: anchorSegments,
|
|
47
|
+
children: content
|
|
48
|
+
}) : content;
|
|
49
|
+
}
|
|
50
|
+
function AccordionContent(props) {
|
|
51
|
+
return /* @__PURE__ */ jsx(Accordion.Panel, {
|
|
52
|
+
...props,
|
|
53
|
+
className: cn("h-(--accordion-panel-height) overflow-hidden transition-[height] ease-out data-ending-style:h-0 data-starting-style:h-0", props.className)
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function AccordionHeader(props) {
|
|
57
|
+
return /* @__PURE__ */ jsx(Accordion.Header, {
|
|
58
|
+
...props,
|
|
59
|
+
className: cn("not-prose flex text-fd-foreground font-medium", props.className),
|
|
60
|
+
children: props.children
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function AccordionTrigger(props) {
|
|
64
|
+
return /* @__PURE__ */ jsxs(Accordion.Trigger, {
|
|
65
|
+
...props,
|
|
66
|
+
className: cn("flex flex-1 items-center gap-1 text-start group/accordion py-2 focus-visible:outline-none", props.className),
|
|
67
|
+
children: [/* @__PURE__ */ jsx(ChevronRight, { className: "size-3.5 text-fd-muted-foreground shrink-0 transition-transform group-data-[panel-open]/accordion:rotate-90" }), props.children]
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { AccordionContent, AccordionHeader, AccordionItem, AccordionTrigger, Accordions };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { cn } from "../utils/cn.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
//#region ../shared-api/dist/components/badge.js
|
|
5
|
+
const badgeVariants = cva("font-mono font-medium", { variants: { color: {
|
|
6
|
+
green: "text-green-600 dark:text-green-400",
|
|
7
|
+
yellow: "text-yellow-600 dark:text-yellow-400",
|
|
8
|
+
red: "text-red-600 dark:text-red-400",
|
|
9
|
+
blue: "text-blue-600 dark:text-blue-400",
|
|
10
|
+
orange: "text-orange-600 dark:text-orange-400",
|
|
11
|
+
gray: "text-fd-muted-foreground"
|
|
12
|
+
} } });
|
|
13
|
+
function Badge({ className, color, ...props }) {
|
|
14
|
+
return /* @__PURE__ */ jsx("span", {
|
|
15
|
+
className: cn(badgeVariants({ color }), className),
|
|
16
|
+
...props,
|
|
17
|
+
children: props.children
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { Badge, badgeVariants };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import { Collapsible } from "@base-ui/react/collapsible";
|
|
3
|
+
//#region ../shared-api/dist/components/collapsible.d.ts
|
|
4
|
+
//#region src/components/collapsible.d.ts
|
|
5
|
+
declare const Collapsible$1: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").CollapsibleRootProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { Collapsible$1 as Collapsible };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../utils/cn.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { Collapsible } from "@base-ui/react/collapsible";
|
|
5
|
+
//#region ../shared-api/dist/components/collapsible.js
|
|
6
|
+
const Collapsible$1 = Collapsible.Root;
|
|
7
|
+
const CollapsibleTrigger = Collapsible.Trigger;
|
|
8
|
+
function CollapsibleContent({ children, className, ...props }) {
|
|
9
|
+
return /* @__PURE__ */ jsx(Collapsible.Panel, {
|
|
10
|
+
...props,
|
|
11
|
+
className: (s) => cn("overflow-hidden [&[hidden]:not([hidden='until-found'])]:hidden h-(--collapsible-panel-height) transition-[height,opacity] data-starting-style:opacity-0 data-starting-style:h-0 data-ending-style:h-0 data-ending-style:opacity-0", typeof className === "function" ? className(s) : className),
|
|
12
|
+
children
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { Collapsible$1 as Collapsible, CollapsibleContent, CollapsibleTrigger };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ComponentProps, FC } from "react";
|
|
2
|
+
import { DynamicCodeblockProps } from "fumadocs-ui/components/dynamic-codeblock.core";
|
|
3
|
+
import { ShikiFactory } from "fumadocs-core/highlight/shiki";
|
|
4
|
+
import { BundledTheme, CodeOptionsThemes, CodeToHastOptionsCommon } from "shiki";
|
|
5
|
+
//#region ../shared-api/dist/components/defaults.d.ts
|
|
6
|
+
//#region src/components/defaults.d.ts
|
|
7
|
+
export type CodeBlockProps = Omit<DynamicCodeblockProps, 'highlighter' | 'options'>;
|
|
8
|
+
export type ShikiOptions = Omit<CodeToHastOptionsCommon, 'lang'> & CodeOptionsThemes<BundledTheme>;
|
|
9
|
+
/** components an API page renders its content through */
|
|
10
|
+
export interface PageComponents {
|
|
11
|
+
Markdown: FC<{
|
|
12
|
+
md: string;
|
|
13
|
+
}>;
|
|
14
|
+
CodeBlock: FC<CodeBlockProps>;
|
|
15
|
+
Heading: FC<ComponentProps<'h1'> & {
|
|
16
|
+
id: string;
|
|
17
|
+
depth: number;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Children, useMemo } from "react";
|
|
3
|
+
import * as JsxRuntime from "react/jsx-runtime";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { remark } from "remark";
|
|
6
|
+
import remarkRehype from "remark-rehype";
|
|
7
|
+
import { remarkGfm } from "fumadocs-core/mdx-plugins/remark-gfm";
|
|
8
|
+
import { toJsxRuntime } from "hast-util-to-jsx-runtime";
|
|
9
|
+
import defaultMdxComponents from "fumadocs-ui/mdx";
|
|
10
|
+
import { Heading } from "fumadocs-ui/components/heading";
|
|
11
|
+
import { DynamicCodeBlock } from "fumadocs-ui/components/dynamic-codeblock.core";
|
|
12
|
+
//#region ../shared-api/dist/components/defaults.js
|
|
13
|
+
const defaultShikiOptions = { themes: {
|
|
14
|
+
light: "github-light",
|
|
15
|
+
dark: "github-dark"
|
|
16
|
+
} };
|
|
17
|
+
/**
|
|
18
|
+
* The default Markdown, code block and heading components of API pages.
|
|
19
|
+
*
|
|
20
|
+
* Markdown is rendered with Remark, its code blocks go through {@link PageComponents}.
|
|
21
|
+
*/
|
|
22
|
+
function createPageComponents({ shiki, shikiOptions = defaultShikiOptions, components }) {
|
|
23
|
+
const CodeBlock = components.CodeBlock ?? ((props) => /* @__PURE__ */ jsx(DynamicCodeBlock, {
|
|
24
|
+
highlighter: () => shiki.getOrInit(),
|
|
25
|
+
options: shikiOptions,
|
|
26
|
+
...props
|
|
27
|
+
}));
|
|
28
|
+
let processor;
|
|
29
|
+
return {
|
|
30
|
+
CodeBlock,
|
|
31
|
+
Markdown: components.Markdown ?? (({ md }) => useMemo(() => {
|
|
32
|
+
processor ??= createProcessor(CodeBlock);
|
|
33
|
+
return processor.processSync(md).result;
|
|
34
|
+
}, [md])),
|
|
35
|
+
Heading: components.Heading ?? (({ depth, ...props }) => /* @__PURE__ */ jsx(Heading, {
|
|
36
|
+
as: `h${depth}`,
|
|
37
|
+
...props
|
|
38
|
+
}))
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function createProcessor(CodeBlock) {
|
|
42
|
+
function Pre(props) {
|
|
43
|
+
const codeProps = Children.only(props.children).props;
|
|
44
|
+
const content = codeProps.children;
|
|
45
|
+
if (typeof content !== "string") return null;
|
|
46
|
+
const lang = codeProps.className?.split(" ").find((v) => v.startsWith("language-"))?.slice(9) ?? "text";
|
|
47
|
+
return /* @__PURE__ */ jsx(CodeBlock, {
|
|
48
|
+
lang,
|
|
49
|
+
code: content.trimEnd()
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
const mdxComponents = {
|
|
53
|
+
...defaultMdxComponents,
|
|
54
|
+
img: void 0,
|
|
55
|
+
pre: Pre
|
|
56
|
+
};
|
|
57
|
+
function rehypeReact() {
|
|
58
|
+
this.compiler = (tree, file) => {
|
|
59
|
+
return toJsxRuntime(tree, {
|
|
60
|
+
development: false,
|
|
61
|
+
filePath: file.path,
|
|
62
|
+
...JsxRuntime,
|
|
63
|
+
components: mdxComponents
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return remark().use(remarkGfm).use(remarkRehype).use(rehypeReact);
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
export { createPageComponents, defaultShikiOptions };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../utils/cn.js";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { X } from "lucide-react";
|
|
5
|
+
import { buttonVariants } from "fumadocs-ui/components/ui/button";
|
|
6
|
+
import { Dialog } from "@base-ui/react/dialog";
|
|
7
|
+
//#region ../shared-api/dist/components/dialog.js
|
|
8
|
+
const Dialog$1 = Dialog.Root;
|
|
9
|
+
const DialogTrigger = Dialog.Trigger;
|
|
10
|
+
const DialogPortal = Dialog.Portal;
|
|
11
|
+
Dialog.Close;
|
|
12
|
+
function DialogOverlay({ className, ref, ...props }) {
|
|
13
|
+
return /* @__PURE__ */ jsx(Dialog.Backdrop, {
|
|
14
|
+
ref,
|
|
15
|
+
className: cn("fixed inset-0 z-50 bg-black/30 backdrop-blur-sm data-open:animate-fd-fade-in data-closed:animate-fd-fade-out", className),
|
|
16
|
+
...props
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function DialogContent({ className, children, ref, ...props }) {
|
|
20
|
+
return /* @__PURE__ */ jsxs(DialogPortal, { children: [/* @__PURE__ */ jsx(DialogOverlay, {}), /* @__PURE__ */ jsxs(Dialog.Popup, {
|
|
21
|
+
ref,
|
|
22
|
+
className: cn("fixed left-1/2 top-1/2 z-50 flex flex-col gap-4 w-full max-w-lg -translate-x-1/2 -translate-y-1/2 border bg-fd-popover p-4 shadow-lg rounded-xl duration-200 data-open:animate-fd-dialog-in data-closed:animate-fd-dialog-out focus-visible:outline-none", className),
|
|
23
|
+
...props,
|
|
24
|
+
children: [children, /* @__PURE__ */ jsx(Dialog.Close, {
|
|
25
|
+
"aria-label": "Close",
|
|
26
|
+
className: cn(buttonVariants({
|
|
27
|
+
size: "icon-sm",
|
|
28
|
+
variant: "ghost"
|
|
29
|
+
}), "absolute end-2 top-2 text-fd-muted-foreground/70"),
|
|
30
|
+
children: /* @__PURE__ */ jsx(X, {})
|
|
31
|
+
})]
|
|
32
|
+
})] });
|
|
33
|
+
}
|
|
34
|
+
function DialogHeader({ className, ...props }) {
|
|
35
|
+
return /* @__PURE__ */ jsx("div", {
|
|
36
|
+
className: cn("flex flex-col gap-1.5 text-center sm:text-start", className),
|
|
37
|
+
...props
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function DialogTitle({ className, ref, ...props }) {
|
|
41
|
+
return /* @__PURE__ */ jsx(Dialog.Title, {
|
|
42
|
+
ref,
|
|
43
|
+
className: cn("text-lg font-semibold leading-none tracking-tight", className),
|
|
44
|
+
...props
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function DialogDescription({ className, ref, ...props }) {
|
|
48
|
+
return /* @__PURE__ */ jsx(Dialog.Description, {
|
|
49
|
+
ref,
|
|
50
|
+
className: cn("text-sm text-fd-muted-foreground", className),
|
|
51
|
+
...props
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { Dialog$1 as Dialog, DialogContent, DialogDescription, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { cn } from "../utils/cn.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region ../shared-api/dist/components/input.js
|
|
5
|
+
function Input({ className, type, ref, ...props }) {
|
|
6
|
+
return /* @__PURE__ */ jsx("input", {
|
|
7
|
+
type,
|
|
8
|
+
className: cn("flex h-9 w-full rounded-md border bg-fd-secondary px-2 py-1.5 text-[0.8125rem] text-fd-secondary-foreground transition-colors placeholder:text-fd-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-fd-ring disabled:cursor-not-allowed disabled:opacity-50", className),
|
|
9
|
+
ref,
|
|
10
|
+
...props
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { Input };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { cn } from "../utils/cn.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region ../shared-api/dist/components/label.js
|
|
4
|
+
function Label({ className, ...props }) {
|
|
5
|
+
return /* @__PURE__ */ jsx("label", {
|
|
6
|
+
className: cn("text-xs font-medium text-fd-foreground peer-disabled:cursor-not-allowed peer-disabled:opacity-70", className),
|
|
7
|
+
...props
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { Label };
|