fumadocs-openapi 10.3.15 → 10.3.17
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 +2 -0
- package/dist/generate-file.d.ts +0 -1
- package/dist/generate-file.d.ts.map +1 -1
- package/dist/generate-file.js +1 -2
- package/dist/generate-file.js.map +1 -1
- package/dist/index.js +1 -2
- package/dist/playground/client.d.ts +4 -3
- package/dist/playground/client.d.ts.map +1 -1
- package/dist/playground/client.js +2 -4
- package/dist/playground/client.js.map +1 -1
- package/dist/playground/components/inputs.js +2 -4
- package/dist/playground/components/inputs.js.map +1 -1
- package/dist/playground/components/oauth-dialog.js +1 -2
- package/dist/playground/components/oauth-dialog.js.map +1 -1
- package/dist/playground/components/server-select.js +2 -4
- package/dist/playground/components/server-select.js.map +1 -1
- package/dist/playground/fetcher.d.ts +0 -2
- package/dist/playground/fetcher.d.ts.map +1 -1
- package/dist/playground/fetcher.js +1 -2
- package/dist/playground/fetcher.js.map +1 -1
- package/dist/playground/index.d.ts +2 -7
- package/dist/playground/index.d.ts.map +1 -1
- package/dist/playground/index.js +23 -3
- package/dist/playground/index.js.map +1 -1
- package/dist/playground/lazy.js +2 -4
- package/dist/playground/lazy.js.map +1 -1
- package/dist/playground/schema.d.ts +0 -3
- package/dist/playground/schema.d.ts.map +1 -1
- package/dist/playground/schema.js +1 -2
- package/dist/playground/schema.js.map +1 -1
- package/dist/playground/status-info.js +1 -2
- package/dist/playground/status-info.js.map +1 -1
- package/dist/requests/generators/all.js +1 -2
- package/dist/requests/generators/all.js.map +1 -1
- package/dist/requests/generators/csharp.js +1 -2
- package/dist/requests/generators/csharp.js.map +1 -1
- package/dist/requests/generators/curl.js +1 -2
- package/dist/requests/generators/curl.js.map +1 -1
- package/dist/requests/generators/go.js +1 -2
- package/dist/requests/generators/go.js.map +1 -1
- package/dist/requests/generators/index.js +1 -1
- package/dist/requests/generators/java.js +1 -2
- package/dist/requests/generators/java.js.map +1 -1
- package/dist/requests/generators/javascript.js +1 -2
- package/dist/requests/generators/javascript.js.map +1 -1
- package/dist/requests/generators/python.js +1 -2
- package/dist/requests/generators/python.js.map +1 -1
- package/dist/requests/media/adapter.js +2 -3
- package/dist/requests/media/adapter.js.map +1 -1
- package/dist/requests/media/encode.d.ts +0 -4
- package/dist/requests/media/encode.d.ts.map +1 -1
- package/dist/requests/media/encode.js +1 -2
- package/dist/requests/media/encode.js.map +1 -1
- package/dist/requests/media/resolve-adapter.js +1 -1
- package/dist/requests/media/resolve-adapter.js.map +1 -1
- package/dist/requests/string-utils.js +1 -2
- package/dist/requests/string-utils.js.map +1 -1
- package/dist/requests/to-python-object.js +1 -1
- package/dist/scalar/client.js +2 -4
- package/dist/scalar/client.js.map +1 -1
- package/dist/scalar/index.d.ts +0 -2
- package/dist/scalar/index.d.ts.map +1 -1
- package/dist/scalar/index.js +1 -2
- package/dist/scalar/index.js.map +1 -1
- package/dist/server/create.js +1 -2
- package/dist/server/create.js.map +1 -1
- package/dist/server/index.js +1 -2
- package/dist/server/proxy.js +1 -1
- package/dist/server/proxy.js.map +1 -1
- package/dist/server/source-api.js +1 -2
- package/dist/server/source-api.js.map +1 -1
- package/dist/types.d.ts +1 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/api-page.d.ts +0 -2
- package/dist/ui/api-page.d.ts.map +1 -1
- package/dist/ui/api-page.js +1 -2
- package/dist/ui/api-page.js.map +1 -1
- package/dist/ui/base.d.ts +8 -4
- package/dist/ui/base.d.ts.map +1 -1
- package/dist/ui/base.js +12 -4
- package/dist/ui/base.js.map +1 -1
- package/dist/ui/client/index.js +2 -3
- package/dist/ui/client/index.js.map +1 -1
- package/dist/ui/client/storage-key.js +1 -2
- package/dist/ui/client/storage-key.js.map +1 -1
- package/dist/ui/components/accordion.js +2 -4
- package/dist/ui/components/accordion.js.map +1 -1
- package/dist/ui/components/dialog.js +3 -5
- package/dist/ui/components/dialog.js.map +1 -1
- package/dist/ui/components/input.js +1 -2
- package/dist/ui/components/input.js.map +1 -1
- package/dist/ui/components/method-label.js +1 -2
- package/dist/ui/components/method-label.js.map +1 -1
- package/dist/ui/components/select.js +2 -3
- package/dist/ui/components/select.js.map +1 -1
- package/dist/ui/contexts/api.js +2 -4
- package/dist/ui/contexts/api.js.map +1 -1
- package/dist/ui/contexts/api.lazy.js +2 -4
- package/dist/ui/contexts/api.lazy.js.map +1 -1
- package/dist/ui/full.client.js +2 -4
- package/dist/ui/full.client.js.map +1 -1
- package/dist/ui/full.d.ts +0 -1
- package/dist/ui/full.d.ts.map +1 -1
- package/dist/ui/full.js +1 -2
- package/dist/ui/full.js.map +1 -1
- package/dist/ui/index.js +1 -2
- package/dist/ui/operation/client.js +2 -4
- package/dist/ui/operation/client.js.map +1 -1
- package/dist/ui/operation/index.js +1 -2
- package/dist/ui/operation/index.js.map +1 -1
- package/dist/ui/operation/request-tabs.d.ts +0 -4
- package/dist/ui/operation/request-tabs.d.ts.map +1 -1
- package/dist/ui/operation/request-tabs.js +1 -2
- package/dist/ui/operation/request-tabs.js.map +1 -1
- package/dist/ui/operation/response-tabs.js +1 -2
- package/dist/ui/operation/response-tabs.js.map +1 -1
- package/dist/ui/operation/usage-tabs/client.js +4 -7
- package/dist/ui/operation/usage-tabs/client.js.map +1 -1
- package/dist/ui/operation/usage-tabs/index.js +1 -2
- package/dist/ui/operation/usage-tabs/index.js.map +1 -1
- package/dist/ui/operation/usage-tabs/lazy.js +2 -4
- package/dist/ui/operation/usage-tabs/lazy.js.map +1 -1
- package/dist/ui/schema/client.d.ts +0 -2
- package/dist/ui/schema/client.d.ts.map +1 -1
- package/dist/ui/schema/client.js +2 -4
- package/dist/ui/schema/client.js.map +1 -1
- package/dist/ui/schema/index.d.ts +0 -3
- package/dist/ui/schema/index.d.ts.map +1 -1
- package/dist/ui/schema/index.js +1 -2
- package/dist/ui/schema/index.js.map +1 -1
- package/dist/ui/schema/lazy.js +2 -4
- package/dist/ui/schema/lazy.js.map +1 -1
- package/dist/utils/cn.js +1 -2
- package/dist/utils/deep-equal.js +1 -1
- package/dist/utils/id-to-title.js +1 -1
- package/dist/utils/lazy.js +1 -2
- package/dist/utils/lazy.js.map +1 -1
- package/dist/utils/merge-schema.js +1 -2
- package/dist/utils/merge-schema.js.map +1 -1
- package/dist/utils/pages/builder.d.ts +0 -1
- package/dist/utils/pages/builder.d.ts.map +1 -1
- package/dist/utils/pages/builder.js +1 -2
- package/dist/utils/pages/builder.js.map +1 -1
- package/dist/utils/pages/preset-auto.js +1 -2
- package/dist/utils/pages/preset-auto.js.map +1 -1
- package/dist/utils/pages/to-body.js +1 -1
- package/dist/utils/pages/to-static-data.js +1 -2
- package/dist/utils/pages/to-static-data.js.map +1 -1
- package/dist/utils/pages/to-text.d.ts +0 -3
- package/dist/utils/pages/to-text.d.ts.map +1 -1
- package/dist/utils/pages/to-text.js +1 -2
- package/dist/utils/pages/to-text.js.map +1 -1
- package/dist/utils/process-document.js +3 -5
- package/dist/utils/process-document.js.map +1 -1
- package/dist/utils/remove-undefined.js +1 -1
- package/dist/utils/remove-undefined.js.map +1 -1
- package/dist/utils/schema-to-string.d.ts +1 -2
- package/dist/utils/schema-to-string.js +1 -1
- package/dist/utils/schema-to-string.js.map +1 -1
- package/dist/utils/schema.js +1 -2
- package/dist/utils/schema.js.map +1 -1
- package/dist/utils/url.js +1 -1
- package/dist/utils/use-query.js +1 -2
- package/dist/utils/use-query.js.map +1 -1
- package/package.json +11 -11
- package/dist/_virtual/_rolldown/runtime.js +0 -5
- package/dist/node_modules/.pnpm/dereference-json-schema@0.2.1/node_modules/dereference-json-schema/dereference.js +0 -43
- package/dist/node_modules/.pnpm/dereference-json-schema@0.2.1/node_modules/dereference-json-schema/dereference.js.map +0 -1
- package/dist/node_modules/.pnpm/dereference-json-schema@0.2.1/node_modules/dereference-json-schema/index.js +0 -29
- package/dist/node_modules/.pnpm/dereference-json-schema@0.2.1/node_modules/dereference-json-schema/index.js.map +0 -1
- package/dist/node_modules/.pnpm/dereference-json-schema@0.2.1/node_modules/dereference-json-schema/klona.js +0 -42
- package/dist/node_modules/.pnpm/dereference-json-schema@0.2.1/node_modules/dereference-json-schema/klona.js.map +0 -1
- package/dist/node_modules/.pnpm/dereference-json-schema@0.2.1/node_modules/dereference-json-schema/resolveRef.js +0 -46
- package/dist/node_modules/.pnpm/dereference-json-schema@0.2.1/node_modules/dereference-json-schema/resolveRef.js.map +0 -1
- package/dist/node_modules/.pnpm/dereference-json-schema@0.2.1/node_modules/dereference-json-schema/types.js +0 -12
- package/dist/node_modules/.pnpm/dereference-json-schema@0.2.1/node_modules/dereference-json-schema/types.js.map +0 -1
package/dist/ui/base.js
CHANGED
|
@@ -12,7 +12,6 @@ import { remark } from "remark";
|
|
|
12
12
|
import remarkRehype from "remark-rehype";
|
|
13
13
|
import { toJsxRuntime } from "hast-util-to-jsx-runtime";
|
|
14
14
|
import { CodeBlock, Pre } from "fumadocs-ui/components/codeblock";
|
|
15
|
-
|
|
16
15
|
//#region src/ui/base.tsx
|
|
17
16
|
function createAPIPage(server, options) {
|
|
18
17
|
let processor;
|
|
@@ -46,8 +45,13 @@ function createAPIPage(server, options) {
|
|
|
46
45
|
...options.mediaAdapters
|
|
47
46
|
},
|
|
48
47
|
slugger,
|
|
49
|
-
renderHeading(depth, text, props) {
|
|
48
|
+
async renderHeading(depth, text, props) {
|
|
50
49
|
const id = slugger.slug(text);
|
|
50
|
+
if (options.renderHeading) return options.renderHeading({
|
|
51
|
+
id,
|
|
52
|
+
children: text,
|
|
53
|
+
...props
|
|
54
|
+
}, depth);
|
|
51
55
|
return /* @__PURE__ */ jsx(Heading, {
|
|
52
56
|
id,
|
|
53
57
|
as: `h${depth}`,
|
|
@@ -69,13 +73,17 @@ function createAPIPage(server, options) {
|
|
|
69
73
|
return (await processor.process({ value: text })).result;
|
|
70
74
|
},
|
|
71
75
|
async renderCodeBlock(lang, code) {
|
|
76
|
+
if (options.renderCodeBlock) return options.renderCodeBlock({
|
|
77
|
+
lang,
|
|
78
|
+
code
|
|
79
|
+
});
|
|
72
80
|
return /* @__PURE__ */ jsx(CodeBlock, {
|
|
73
81
|
className: "my-0",
|
|
74
82
|
children: await highlight(code, {
|
|
75
83
|
lang,
|
|
76
84
|
...options.shikiOptions,
|
|
77
85
|
config: options.shiki,
|
|
78
|
-
components: { pre:
|
|
86
|
+
components: { pre: Pre }
|
|
79
87
|
})
|
|
80
88
|
});
|
|
81
89
|
}
|
|
@@ -86,7 +94,7 @@ function createAPIPage(server, options) {
|
|
|
86
94
|
});
|
|
87
95
|
};
|
|
88
96
|
}
|
|
89
|
-
|
|
90
97
|
//#endregion
|
|
91
98
|
export { createAPIPage };
|
|
99
|
+
|
|
92
100
|
//# sourceMappingURL=base.js.map
|
package/dist/ui/base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","names":[],"sources":["../../src/ui/base.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any -- rehype-react without types */\nimport Slugger from 'github-slugger';\nimport type { Awaitable, DistributiveOmit, MethodInformation, RenderContext } from '@/types';\nimport type { NoReference } from '@/utils/schema';\nimport type { ProcessedDocument } from '@/utils/process-document';\nimport { defaultAdapters, MediaAdapter } from '@/requests/media/adapter';\nimport type { FC, ReactNode } from 'react';\nimport { highlight, type CoreHighlightOptions } from 'fumadocs-core/highlight/core';\nimport type { OpenAPIServer } from '@/server';\nimport type { APIPageClientOptions } from './client';\nimport { Heading } from 'fumadocs-ui/components/heading';\nimport { createRehypeCode } from 'fumadocs-core/mdx-plugins/rehype-code.core';\nimport { remarkGfm } from 'fumadocs-core/mdx-plugins/remark-gfm';\nimport defaultMdxComponents from 'fumadocs-ui/mdx';\nimport { remark } from 'remark';\nimport remarkRehype from 'remark-rehype';\nimport { toJsxRuntime } from 'hast-util-to-jsx-runtime';\nimport * as JsxRuntime from 'react/jsx-runtime';\nimport { CodeBlock, Pre } from 'fumadocs-ui/components/codeblock';\nimport type { SchemaUIOptions } from './schema';\nimport type { ResponseTab } from './operation/response-tabs';\nimport type { ExampleRequestItem } from './operation/request-tabs';\nimport type { ResolvedShikiConfig } from 'fumadocs-core/highlight/config';\nimport { APIPage, type ApiPageProps, type OperationItem, type WebhookItem } from './api-page';\nimport type { CodeUsageGeneratorRegistry, InlineCodeUsageGenerator } from '@/requests/generators';\nimport type { JSONSchema } from 'json-schema-typed';\n\nexport interface GenerateTypeScriptDefinitionsContext extends RenderContext {\n operation: NoReference<MethodInformation>;\n readOnly: boolean;\n writeOnly: boolean;\n /** @deprecated */\n _internal_legacy?: {\n statusCode: string;\n contentType: string;\n };\n}\n\nexport interface CreateAPIPageOptions {\n /**\n * Generate TypeScript definitions from response schema.\n *\n * Pass `false` to disable it.\n *\n * @param method - the operation object\n * @param statusCode - status code\n * @deprecated use `generateTypeScriptDefinitions` instead.\n */\n generateTypeScriptSchema?:\n | ((\n method: NoReference<MethodInformation>,\n statusCode: string,\n contentType: string,\n ctx: RenderContext,\n ) => Awaitable<string | undefined>)\n | false;\n\n /**\n * Generate TypeScript definitions from JSON schema.\n *\n * Pass `false` to disable it.\n */\n generateTypeScriptDefinitions?: (\n schema: JSONSchema,\n ctx: GenerateTypeScriptDefinitionsContext,\n ) => Awaitable<string | undefined>;\n\n /**\n * Generate example code usage for endpoints.\n */\n codeUsages?: CodeUsageGeneratorRegistry;\n\n /**\n * Generate example code usage for endpoints.\n */\n generateCodeSamples?: (method: MethodInformation) => Awaitable<InlineCodeUsageGenerator[]>;\n\n shiki: ResolvedShikiConfig;\n renderMarkdown?: (md: string) => ReactNode;\n shikiOptions?: DistributiveOmit<CoreHighlightOptions, 'config' | 'lang' | 'components'>;\n\n /**\n * Show full response schema instead of only example response & Typescript definitions.\n *\n * @default true\n */\n showResponseSchema?: boolean;\n\n /**\n * Support other media types (for server-side generation).\n */\n mediaAdapters?: Record<string, MediaAdapter>;\n\n /**\n * Customise page content\n */\n content?: {\n renderResponseTabs?: (tabs: ResponseTab[], ctx: RenderContext) => Awaitable<ReactNode>;\n\n renderRequestTabs?: (\n items: ExampleRequestItem[],\n ctx: RenderContext & {\n route: string;\n operation: NoReference<MethodInformation>;\n },\n ) => Awaitable<ReactNode>;\n\n renderAPIExampleLayout?: (\n slots: {\n selector: ReactNode;\n usageTabs: ReactNode;\n responseTabs: ReactNode;\n },\n ctx: RenderContext,\n ) => Awaitable<ReactNode>;\n\n /**\n * @param generators - codegens for API example usages\n */\n renderAPIExampleUsageTabs?: (\n generators: CodeUsageGeneratorRegistry,\n ctx: RenderContext,\n ) => Awaitable<ReactNode>;\n\n /**\n * renderer of the entire page's layout (containing all operations & webhooks UI)\n */\n renderPageLayout?: (\n slots: {\n operations?: {\n item: OperationItem;\n children: ReactNode;\n }[];\n webhooks?: {\n item: WebhookItem;\n children: ReactNode;\n }[];\n },\n ctx: RenderContext,\n ) => Awaitable<ReactNode>;\n\n renderOperationLayout?: (\n slots: {\n header: ReactNode;\n description: ReactNode;\n apiExample: ReactNode;\n apiPlayground: ReactNode;\n\n authSchemes: ReactNode;\n paremeters: ReactNode;\n body: ReactNode;\n responses: ReactNode;\n callbacks: ReactNode;\n },\n ctx: RenderContext,\n method: NoReference<MethodInformation>,\n ) => Awaitable<ReactNode>;\n\n renderWebhookLayout?: (slots: {\n header: ReactNode;\n description: ReactNode;\n authSchemes: ReactNode;\n paremeters: ReactNode;\n body: ReactNode;\n requests: ReactNode;\n responses: ReactNode;\n callbacks: ReactNode;\n }) => Awaitable<ReactNode>;\n };\n\n /**\n * Info UI for JSON schemas\n */\n schemaUI?: {\n render?: (options: SchemaUIOptions, ctx: RenderContext) => Awaitable<ReactNode>;\n\n /**\n * Show examples under the generated content of JSON schemas.\n *\n * @defaultValue false\n */\n showExample?: boolean;\n };\n\n /**\n * Customise API playground\n */\n playground?: {\n /**\n * @defaultValue true\n */\n enabled?: boolean;\n /**\n * replace the server-side renderer\n */\n render?: (props: {\n path: string;\n method: MethodInformation;\n ctx: RenderContext;\n }) => Awaitable<ReactNode>;\n };\n\n client?: APIPageClientOptions;\n}\n\nexport function createAPIPage(\n server: OpenAPIServer,\n options: CreateAPIPageOptions,\n): FC<ApiPageProps> {\n let processor: ReturnType<typeof createMarkdownProcessor>;\n\n function createMarkdownProcessor() {\n function rehypeReact(this: any) {\n this.compiler = (tree: any, file: any) => {\n return toJsxRuntime(tree, {\n development: false,\n filePath: file.path,\n ...JsxRuntime,\n components: defaultMdxComponents,\n });\n };\n }\n\n return remark()\n .use(remarkGfm)\n .use(remarkRehype)\n .use(createRehypeCode(options.shiki), {\n langs: [],\n lazy: true,\n })\n .use(rehypeReact);\n }\n\n return async function APIPageWrapper({ document, ...props }) {\n let processed: ProcessedDocument;\n if (typeof document === 'string') {\n processed = await server.getSchema(document);\n } else {\n processed = await document;\n }\n\n const slugger = new Slugger();\n\n const ctx: RenderContext = {\n schema: processed,\n proxyUrl: server.options.proxyUrl,\n ...options,\n mediaAdapters: {\n ...defaultAdapters,\n ...options.mediaAdapters,\n },\n slugger,\n renderHeading(depth, text, props) {\n const id = slugger.slug(text);\n\n return (\n <Heading id={id} key={id} as={`h${depth}` as `h1`} {...props}>\n {text}\n </Heading>\n );\n },\n generateTypeScriptDefinitions(schema, ctx) {\n const { generateTypeScriptSchema, generateTypeScriptDefinitions } = options;\n if (generateTypeScriptSchema && ctx._internal_legacy) {\n const { statusCode, contentType } = ctx._internal_legacy;\n return generateTypeScriptSchema(ctx.operation, statusCode, contentType, ctx);\n }\n\n return generateTypeScriptDefinitions?.(schema, ctx);\n },\n async renderMarkdown(text) {\n if (options.renderMarkdown) return options.renderMarkdown(text);\n processor ??= createMarkdownProcessor();\n\n const out = await processor.process({\n value: text,\n });\n\n return out.result as ReactNode;\n },\n async renderCodeBlock(lang, code) {\n const rendered = await highlight(code, {\n lang,\n ...options.shikiOptions,\n config: options.shiki,\n components: {\n pre: (props) => <Pre {...props} />,\n },\n });\n\n return <CodeBlock className=\"my-0\">{rendered}</CodeBlock>;\n },\n };\n\n return <APIPage {...props} ctx={ctx} />;\n };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M,MAAM;AAUhC,WAAO,oBAAC;KAAU,WAAU;eATX,MAAM,UAAU,MAAM;MACrC;MACA,GAAG,QAAQ;MACX,QAAQ,QAAQ;MAChB,YAAY,EACV,MAAM,UAAU,oBAAC,OAAI,GAAI,QAAS,EACnC;MACF,CAAC;MAEuD;;GAE5D;AAED,SAAO,oBAAC;GAAQ,GAAI;GAAY;IAAO"}
|
|
1
|
+
{"version":3,"file":"base.js","names":[],"sources":["../../src/ui/base.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any -- rehype-react without types */\nimport Slugger from 'github-slugger';\nimport type { Awaitable, DistributiveOmit, MethodInformation, RenderContext } from '@/types';\nimport type { NoReference } from '@/utils/schema';\nimport type { ProcessedDocument } from '@/utils/process-document';\nimport { defaultAdapters, MediaAdapter } from '@/requests/media/adapter';\nimport type { FC, HTMLAttributes, ReactNode } from 'react';\nimport { highlight, type CoreHighlightOptions } from 'fumadocs-core/highlight/core';\nimport type { OpenAPIServer } from '@/server';\nimport type { APIPageClientOptions } from './client';\nimport { Heading } from 'fumadocs-ui/components/heading';\nimport { createRehypeCode } from 'fumadocs-core/mdx-plugins/rehype-code.core';\nimport { remarkGfm } from 'fumadocs-core/mdx-plugins/remark-gfm';\nimport defaultMdxComponents from 'fumadocs-ui/mdx';\nimport { remark } from 'remark';\nimport remarkRehype from 'remark-rehype';\nimport { toJsxRuntime } from 'hast-util-to-jsx-runtime';\nimport * as JsxRuntime from 'react/jsx-runtime';\nimport { CodeBlock, Pre } from 'fumadocs-ui/components/codeblock';\nimport type { SchemaUIOptions } from './schema';\nimport type { ResponseTab } from './operation/response-tabs';\nimport type { ExampleRequestItem } from './operation/request-tabs';\nimport type { ResolvedShikiConfig } from 'fumadocs-core/highlight/config';\nimport { APIPage, type ApiPageProps, type OperationItem, type WebhookItem } from './api-page';\nimport type { CodeUsageGeneratorRegistry, InlineCodeUsageGenerator } from '@/requests/generators';\nimport type { JSONSchema } from 'json-schema-typed';\n\nexport interface GenerateTypeScriptDefinitionsContext extends RenderContext {\n operation: NoReference<MethodInformation>;\n readOnly: boolean;\n writeOnly: boolean;\n /** @deprecated */\n _internal_legacy?: {\n statusCode: string;\n contentType: string;\n };\n}\n\nexport interface CreateAPIPageOptions {\n /**\n * Generate TypeScript definitions from response schema.\n *\n * Pass `false` to disable it.\n *\n * @param method - the operation object\n * @param statusCode - status code\n * @deprecated use `generateTypeScriptDefinitions` instead.\n */\n generateTypeScriptSchema?:\n | ((\n method: NoReference<MethodInformation>,\n statusCode: string,\n contentType: string,\n ctx: RenderContext,\n ) => Awaitable<string | undefined>)\n | false;\n\n /**\n * Generate TypeScript definitions from JSON schema.\n *\n * Pass `false` to disable it.\n */\n generateTypeScriptDefinitions?: (\n schema: JSONSchema,\n ctx: GenerateTypeScriptDefinitionsContext,\n ) => Awaitable<string | undefined>;\n\n /**\n * Generate example code usage for all endpoints.\n */\n codeUsages?: CodeUsageGeneratorRegistry;\n\n /**\n * Generate example code usage for each endpoint.\n */\n generateCodeSamples?: (method: MethodInformation) => Awaitable<InlineCodeUsageGenerator[]>;\n\n shiki: ResolvedShikiConfig;\n renderMarkdown?: (md: string) => ReactNode;\n shikiOptions?: DistributiveOmit<CoreHighlightOptions, 'config' | 'lang' | 'components'>;\n\n /**\n * Show full response schema instead of only example response & Typescript definitions.\n *\n * @default true\n */\n showResponseSchema?: boolean;\n\n /**\n * Support other media types (for server-side generation).\n */\n mediaAdapters?: Record<string, MediaAdapter>;\n\n /**\n * Customise page content\n */\n content?: {\n renderResponseTabs?: (tabs: ResponseTab[], ctx: RenderContext) => Awaitable<ReactNode>;\n\n renderRequestTabs?: (\n items: ExampleRequestItem[],\n ctx: RenderContext & {\n route: string;\n operation: NoReference<MethodInformation>;\n },\n ) => Awaitable<ReactNode>;\n\n renderAPIExampleLayout?: (\n slots: {\n selector: ReactNode;\n usageTabs: ReactNode;\n responseTabs: ReactNode;\n },\n ctx: RenderContext,\n ) => Awaitable<ReactNode>;\n\n /**\n * @param generators - codegens for API example usages\n */\n renderAPIExampleUsageTabs?: (\n generators: CodeUsageGeneratorRegistry,\n ctx: RenderContext,\n ) => Awaitable<ReactNode>;\n\n /**\n * renderer of the entire page's layout (containing all operations & webhooks UI)\n */\n renderPageLayout?: (\n slots: {\n operations?: {\n item: OperationItem;\n children: ReactNode;\n }[];\n webhooks?: {\n item: WebhookItem;\n children: ReactNode;\n }[];\n },\n ctx: RenderContext,\n ) => Awaitable<ReactNode>;\n\n renderOperationLayout?: (\n slots: {\n header: ReactNode;\n description: ReactNode;\n apiExample: ReactNode;\n apiPlayground: ReactNode;\n\n authSchemes: ReactNode;\n paremeters: ReactNode;\n body: ReactNode;\n responses: ReactNode;\n callbacks: ReactNode;\n },\n ctx: RenderContext,\n method: NoReference<MethodInformation>,\n ) => Awaitable<ReactNode>;\n\n renderWebhookLayout?: (slots: {\n header: ReactNode;\n description: ReactNode;\n authSchemes: ReactNode;\n paremeters: ReactNode;\n body: ReactNode;\n requests: ReactNode;\n responses: ReactNode;\n callbacks: ReactNode;\n }) => Awaitable<ReactNode>;\n };\n\n /**\n * Info UI for JSON schemas\n */\n schemaUI?: {\n render?: (options: SchemaUIOptions, ctx: RenderContext) => Awaitable<ReactNode>;\n\n /**\n * Show examples under the generated content of JSON schemas.\n *\n * @defaultValue false\n */\n showExample?: boolean;\n };\n\n /**\n * Customise API playground\n */\n playground?: {\n /**\n * @defaultValue true\n */\n enabled?: boolean;\n /**\n * replace the server-side renderer\n */\n render?: (props: {\n path: string;\n method: MethodInformation;\n ctx: RenderContext;\n }) => Awaitable<ReactNode>;\n };\n\n renderHeading?: (\n props: HTMLAttributes<HTMLHeadingElement>,\n depth: number,\n ) => Awaitable<ReactNode>;\n renderCodeBlock?: (props: { lang: string; code: string }) => Awaitable<ReactNode>;\n\n client?: APIPageClientOptions;\n}\n\nexport function createAPIPage(\n server: OpenAPIServer,\n options: CreateAPIPageOptions,\n): FC<ApiPageProps> {\n let processor: ReturnType<typeof createMarkdownProcessor>;\n\n function createMarkdownProcessor() {\n function rehypeReact(this: any) {\n this.compiler = (tree: any, file: any) => {\n return toJsxRuntime(tree, {\n development: false,\n filePath: file.path,\n ...JsxRuntime,\n components: defaultMdxComponents,\n });\n };\n }\n\n return remark()\n .use(remarkGfm)\n .use(remarkRehype)\n .use(createRehypeCode(options.shiki), {\n langs: [],\n lazy: true,\n })\n .use(rehypeReact);\n }\n\n return async function APIPageWrapper({ document, ...props }) {\n let processed: ProcessedDocument;\n if (typeof document === 'string') {\n processed = await server.getSchema(document);\n } else {\n processed = await document;\n }\n\n const slugger = new Slugger();\n\n const ctx: RenderContext = {\n schema: processed,\n proxyUrl: server.options.proxyUrl,\n ...options,\n mediaAdapters: {\n ...defaultAdapters,\n ...options.mediaAdapters,\n },\n slugger,\n async renderHeading(depth, text, props) {\n const id = slugger.slug(text);\n\n if (options.renderHeading) {\n return options.renderHeading({ id, children: text, ...props }, depth);\n }\n\n return (\n <Heading id={id} key={id} as={`h${depth}` as `h1`} {...props}>\n {text}\n </Heading>\n );\n },\n generateTypeScriptDefinitions(schema, ctx) {\n const { generateTypeScriptSchema, generateTypeScriptDefinitions } = options;\n if (generateTypeScriptSchema && ctx._internal_legacy) {\n const { statusCode, contentType } = ctx._internal_legacy;\n return generateTypeScriptSchema(ctx.operation, statusCode, contentType, ctx);\n }\n\n return generateTypeScriptDefinitions?.(schema, ctx);\n },\n async renderMarkdown(text) {\n if (options.renderMarkdown) return options.renderMarkdown(text);\n processor ??= createMarkdownProcessor();\n\n const out = await processor.process({\n value: text,\n });\n\n return out.result as ReactNode;\n },\n async renderCodeBlock(lang, code) {\n if (options.renderCodeBlock) {\n return options.renderCodeBlock({ lang, code });\n }\n\n const rendered = await highlight(code, {\n lang,\n ...options.shikiOptions,\n config: options.shiki,\n components: {\n pre: Pre,\n },\n });\n\n return <CodeBlock className=\"my-0\">{rendered}</CodeBlock>;\n },\n };\n\n return <APIPage {...props} ctx={ctx} />;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;A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Y,MAAM,UAAU,QAAQ,EAClC,OAAO,MACR,CAAC,EAES;;GAEb,MAAM,gBAAgB,MAAM,MAAM;AAChC,QAAI,QAAQ,gBACV,QAAO,QAAQ,gBAAgB;KAAE;KAAM;KAAM,CAAC;AAYhD,WAAO,oBAAC,WAAD;KAAW,WAAU;eATX,MAAM,UAAU,MAAM;MACrC;MACA,GAAG,QAAQ;MACX,QAAQ,QAAQ;MAChB,YAAY,EACV,KAAK,KACN;MACF,CAAC;KAEuD,CAAA;;GAE5D;AAED,SAAO,oBAAC,SAAD;GAAS,GAAI;GAAY;GAAO,CAAA"}
|
package/dist/ui/client/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/ui/client/index.tsx"],"sourcesContent":["'use client';\nimport type { PlaygroundClientOptions } from '@/playground/client';\nimport type { MediaAdapter } from '@/requests/media/adapter';\nimport type { FC } from 'react';\nimport type { ExampleRequestItem } from '../operation/request-tabs';\nimport type { CodeUsageGeneratorRegistry } from '@/requests/generators';\n\nexport interface APIPageClientOptions {\n playground?: PlaygroundClientOptions;\n operation?: OperationClientOptions;\n\n /**\n * Set a prefix for `localStorage` keys.\n *\n * Useful when using multiple OpenAPI instances to prevent state conflicts.\n *\n * @defaultValue `fumadocs-openapi-`\n */\n storageKeyPrefix?: string;\n\n /**\n * Support other media types (for client-side serialization)\n */\n mediaAdapters?: Record<string, MediaAdapter>;\n\n /**\n * generate code usage examples\n */\n codeUsages?: CodeUsageGeneratorRegistry;\n}\n\nexport interface OperationClientOptions {\n APIExampleSelector?: FC<{\n items: ExampleRequestItem[];\n\n value: string | undefined;\n onValueChange: (id: string) => void;\n }>;\n}\n\nexport function defineClientConfig(options: APIPageClientOptions = {}): APIPageClientOptions {\n return options;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/ui/client/index.tsx"],"sourcesContent":["'use client';\nimport type { PlaygroundClientOptions } from '@/playground/client';\nimport type { MediaAdapter } from '@/requests/media/adapter';\nimport type { FC } from 'react';\nimport type { ExampleRequestItem } from '../operation/request-tabs';\nimport type { CodeUsageGeneratorRegistry } from '@/requests/generators';\n\nexport interface APIPageClientOptions {\n playground?: PlaygroundClientOptions;\n operation?: OperationClientOptions;\n\n /**\n * Set a prefix for `localStorage` keys.\n *\n * Useful when using multiple OpenAPI instances to prevent state conflicts.\n *\n * @defaultValue `fumadocs-openapi-`\n */\n storageKeyPrefix?: string;\n\n /**\n * Support other media types (for client-side serialization)\n */\n mediaAdapters?: Record<string, MediaAdapter>;\n\n /**\n * generate code usage examples\n */\n codeUsages?: CodeUsageGeneratorRegistry;\n}\n\nexport interface OperationClientOptions {\n APIExampleSelector?: FC<{\n items: ExampleRequestItem[];\n\n value: string | undefined;\n onValueChange: (id: string) => void;\n }>;\n}\n\nexport function defineClientConfig(options: APIPageClientOptions = {}): APIPageClientOptions {\n return options;\n}\n"],"mappings":";;AAwCA,SAAgB,mBAAmB,UAAgC,EAAE,EAAwB;AAC3F,QAAO"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useApiContext } from "../contexts/api.js";
|
|
2
2
|
import { useMemo } from "react";
|
|
3
|
-
|
|
4
3
|
//#region src/ui/client/storage-key.ts
|
|
5
4
|
function useStorageKey() {
|
|
6
5
|
const { storageKeyPrefix } = useApiContext().client;
|
|
@@ -12,7 +11,7 @@ function useStorageKey() {
|
|
|
12
11
|
function getStorageKey(prefix = "fumadocs-openapi-", name) {
|
|
13
12
|
return prefix + name;
|
|
14
13
|
}
|
|
15
|
-
|
|
16
14
|
//#endregion
|
|
17
15
|
export { useStorageKey };
|
|
16
|
+
|
|
18
17
|
//# sourceMappingURL=storage-key.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-key.js","names":[],"sources":["../../../src/ui/client/storage-key.ts"],"sourcesContent":["import type { AuthField } from '@/playground/client';\nimport { useApiContext } from '../contexts/api';\nimport { useMemo } from 'react';\n\ntype KeyName = 'server-url' | `auth-${string}`;\n\nexport function useStorageKey() {\n const { storageKeyPrefix } = useApiContext().client;\n\n return useMemo(\n () => ({\n of: (name: KeyName) => getStorageKey(storageKeyPrefix, name),\n AuthField: (field: AuthField) =>\n getStorageKey(storageKeyPrefix, `auth-${field.original?.id ?? field.fieldName}`),\n }),\n [storageKeyPrefix],\n );\n}\n\nexport function getStorageKey(prefix = 'fumadocs-openapi-', name: KeyName) {\n return prefix + name;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"storage-key.js","names":[],"sources":["../../../src/ui/client/storage-key.ts"],"sourcesContent":["import type { AuthField } from '@/playground/client';\nimport { useApiContext } from '../contexts/api';\nimport { useMemo } from 'react';\n\ntype KeyName = 'server-url' | `auth-${string}`;\n\nexport function useStorageKey() {\n const { storageKeyPrefix } = useApiContext().client;\n\n return useMemo(\n () => ({\n of: (name: KeyName) => getStorageKey(storageKeyPrefix, name),\n AuthField: (field: AuthField) =>\n getStorageKey(storageKeyPrefix, `auth-${field.original?.id ?? field.fieldName}`),\n }),\n [storageKeyPrefix],\n );\n}\n\nexport function getStorageKey(prefix = 'fumadocs-openapi-', name: KeyName) {\n return prefix + name;\n}\n"],"mappings":";;;AAMA,SAAgB,gBAAgB;CAC9B,MAAM,EAAE,qBAAqB,eAAe,CAAC;AAE7C,QAAO,eACE;EACL,KAAK,SAAkB,cAAc,kBAAkB,KAAK;EAC5D,YAAY,UACV,cAAc,kBAAkB,QAAQ,MAAM,UAAU,MAAM,MAAM,YAAY;EACnF,GACD,CAAC,iBAAiB,CACnB;;AAGH,SAAgB,cAAc,SAAS,qBAAqB,MAAe;AACzE,QAAO,SAAS"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use client";
|
|
3
2
|
import { cn } from "../../utils/cn.js";
|
|
4
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
4
|
import { ChevronRight } from "lucide-react";
|
|
6
5
|
import * as Primitive from "@radix-ui/react-accordion";
|
|
7
|
-
|
|
8
6
|
//#region src/ui/components/accordion.tsx
|
|
9
7
|
function Accordions(props) {
|
|
10
8
|
return /* @__PURE__ */ jsx(Primitive.Root, {
|
|
@@ -40,7 +38,7 @@ function AccordionTrigger(props) {
|
|
|
40
38
|
children: [/* @__PURE__ */ jsx(ChevronRight, { className: "size-3.5 text-fd-muted-foreground shrink-0 transition-transform group-focus-visible/accordion:text-fd-primary group-data-[state=open]/accordion:rotate-90" }), props.children]
|
|
41
39
|
});
|
|
42
40
|
}
|
|
43
|
-
|
|
44
41
|
//#endregion
|
|
45
42
|
export { AccordionContent, AccordionHeader, AccordionItem, AccordionTrigger, Accordions };
|
|
43
|
+
|
|
46
44
|
//# sourceMappingURL=accordion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accordion.js","names":[],"sources":["../../../src/ui/components/accordion.tsx"],"sourcesContent":["'use client';\n\nimport * as Primitive from '@radix-ui/react-accordion';\nimport { ChevronRight } from 'lucide-react';\nimport type { ComponentProps } from 'react';\nimport { cn } from '@/utils/cn';\n\nexport function Accordions(props: ComponentProps<typeof Primitive.Root>) {\n return <Primitive.Root {...props} className={cn('divide-y divide-fd-border', props.className)} />;\n}\n\nexport function AccordionItem(props: ComponentProps<typeof Primitive.Item>) {\n return (\n <Primitive.Item {...props} className={cn('scroll-m-20', props.className)}>\n {props.children}\n </Primitive.Item>\n );\n}\n\nexport function AccordionContent(props: ComponentProps<typeof Primitive.Content>) {\n return (\n <Primitive.Content\n {...props}\n className={cn(\n 'overflow-hidden data-[state=closed]:animate-fd-accordion-up data-[state=open]:animate-fd-accordion-down',\n props.className,\n )}\n >\n {props.children}\n </Primitive.Content>\n );\n}\n\nexport function AccordionHeader(props: ComponentProps<typeof Primitive.Header>) {\n return (\n <Primitive.Header\n {...props}\n className={cn('not-prose flex py-2 text-fd-foreground font-medium', props.className)}\n >\n {props.children}\n </Primitive.Header>\n );\n}\n\nexport function AccordionTrigger(props: ComponentProps<typeof Primitive.Trigger>) {\n return (\n <Primitive.Trigger\n {...props}\n className={cn(\n 'flex flex-1 items-center gap-1 text-start group/accordion focus-visible:outline-none',\n props.className,\n )}\n >\n <ChevronRight className=\"size-3.5 text-fd-muted-foreground shrink-0 transition-transform group-focus-visible/accordion:text-fd-primary group-data-[state=open]/accordion:rotate-90\" />\n {props.children}\n </Primitive.Trigger>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"accordion.js","names":[],"sources":["../../../src/ui/components/accordion.tsx"],"sourcesContent":["'use client';\n\nimport * as Primitive from '@radix-ui/react-accordion';\nimport { ChevronRight } from 'lucide-react';\nimport type { ComponentProps } from 'react';\nimport { cn } from '@/utils/cn';\n\nexport function Accordions(props: ComponentProps<typeof Primitive.Root>) {\n return <Primitive.Root {...props} className={cn('divide-y divide-fd-border', props.className)} />;\n}\n\nexport function AccordionItem(props: ComponentProps<typeof Primitive.Item>) {\n return (\n <Primitive.Item {...props} className={cn('scroll-m-20', props.className)}>\n {props.children}\n </Primitive.Item>\n );\n}\n\nexport function AccordionContent(props: ComponentProps<typeof Primitive.Content>) {\n return (\n <Primitive.Content\n {...props}\n className={cn(\n 'overflow-hidden data-[state=closed]:animate-fd-accordion-up data-[state=open]:animate-fd-accordion-down',\n props.className,\n )}\n >\n {props.children}\n </Primitive.Content>\n );\n}\n\nexport function AccordionHeader(props: ComponentProps<typeof Primitive.Header>) {\n return (\n <Primitive.Header\n {...props}\n className={cn('not-prose flex py-2 text-fd-foreground font-medium', props.className)}\n >\n {props.children}\n </Primitive.Header>\n );\n}\n\nexport function AccordionTrigger(props: ComponentProps<typeof Primitive.Trigger>) {\n return (\n <Primitive.Trigger\n {...props}\n className={cn(\n 'flex flex-1 items-center gap-1 text-start group/accordion focus-visible:outline-none',\n props.className,\n )}\n >\n <ChevronRight className=\"size-3.5 text-fd-muted-foreground shrink-0 transition-transform group-focus-visible/accordion:text-fd-primary group-data-[state=open]/accordion:rotate-90\" />\n {props.children}\n </Primitive.Trigger>\n );\n}\n"],"mappings":";;;;;;AAOA,SAAgB,WAAW,OAA8C;AACvE,QAAO,oBAAC,UAAU,MAAX;EAAgB,GAAI;EAAO,WAAW,GAAG,6BAA6B,MAAM,UAAU;EAAI,CAAA;;AAGnG,SAAgB,cAAc,OAA8C;AAC1E,QACE,oBAAC,UAAU,MAAX;EAAgB,GAAI;EAAO,WAAW,GAAG,eAAe,MAAM,UAAU;YACrE,MAAM;EACQ,CAAA;;AAIrB,SAAgB,iBAAiB,OAAiD;AAChF,QACE,oBAAC,UAAU,SAAX;EACE,GAAI;EACJ,WAAW,GACT,2GACA,MAAM,UACP;YAEA,MAAM;EACW,CAAA;;AAIxB,SAAgB,gBAAgB,OAAgD;AAC9E,QACE,oBAAC,UAAU,QAAX;EACE,GAAI;EACJ,WAAW,GAAG,sDAAsD,MAAM,UAAU;YAEnF,MAAM;EACU,CAAA;;AAIvB,SAAgB,iBAAiB,OAAiD;AAChF,QACE,qBAAC,UAAU,SAAX;EACE,GAAI;EACJ,WAAW,GACT,wFACA,MAAM,UACP;YALH,CAOE,oBAAC,cAAD,EAAc,WAAU,6JAA8J,CAAA,EACrL,MAAM,SACW"}
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use client";
|
|
3
2
|
import { cn } from "../../utils/cn.js";
|
|
4
3
|
import * as React from "react";
|
|
5
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
5
|
import { X } from "lucide-react";
|
|
7
6
|
import { buttonVariants } from "fumadocs-ui/components/ui/button";
|
|
8
7
|
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
9
|
-
|
|
10
8
|
//#region src/ui/components/dialog.tsx
|
|
11
9
|
const Dialog = DialogPrimitive.Root;
|
|
12
10
|
const DialogTrigger = DialogPrimitive.Trigger;
|
|
13
11
|
const DialogPortal = DialogPrimitive.Portal;
|
|
14
|
-
|
|
12
|
+
DialogPrimitive.Close;
|
|
15
13
|
const DialogOverlay = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(DialogPrimitive.Overlay, {
|
|
16
14
|
ref,
|
|
17
15
|
className: cn("fixed inset-0 z-50 bg-black/30 backdrop-blur-sm data-[state=open]:animate-fd-fade-in data-[state=closed]:animate-fd-fade-out", className),
|
|
@@ -54,7 +52,7 @@ const DialogDescription = React.forwardRef(({ className, ...props }, ref) => /*
|
|
|
54
52
|
...props
|
|
55
53
|
}));
|
|
56
54
|
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
57
|
-
|
|
58
55
|
//#endregion
|
|
59
56
|
export { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger };
|
|
57
|
+
|
|
60
58
|
//# sourceMappingURL=dialog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.js","names":[],"sources":["../../../src/ui/components/dialog.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport * as DialogPrimitive from '@radix-ui/react-dialog';\nimport { X } from 'lucide-react';\nimport { cn } from '@/utils/cn';\nimport { buttonVariants } from 'fumadocs-ui/components/ui/button';\n\nconst Dialog = DialogPrimitive.Root;\n\nconst DialogTrigger = DialogPrimitive.Trigger;\n\nconst DialogPortal = DialogPrimitive.Portal;\n\nconst DialogClose = DialogPrimitive.Close;\n\nconst DialogOverlay = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Overlay>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n className={cn(\n 'fixed inset-0 z-50 bg-black/30 backdrop-blur-sm data-[state=open]:animate-fd-fade-in data-[state=closed]:animate-fd-fade-out',\n className,\n )}\n {...props}\n />\n));\nDialogOverlay.displayName = DialogPrimitive.Overlay.displayName;\n\nconst DialogContent = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>\n>(({ className, children, ...props }, ref) => (\n <DialogPortal>\n <DialogOverlay />\n <DialogPrimitive.Content\n ref={ref}\n className={cn(\n '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-[state=open]:animate-fd-dialog-in data-[state=closed]:animate-fd-dialog-out focus-visible:outline-none',\n className,\n )}\n {...props}\n >\n {children}\n <DialogPrimitive.Close\n aria-label=\"Close\"\n className={cn(\n buttonVariants({ size: 'icon-sm', color: 'ghost' }),\n 'absolute end-2 top-2 text-fd-muted-foreground/70',\n )}\n >\n <X />\n </DialogPrimitive.Close>\n </DialogPrimitive.Content>\n </DialogPortal>\n));\nDialogContent.displayName = DialogPrimitive.Content.displayName;\n\nconst DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div className={cn('flex flex-col gap-1.5 text-center sm:text-start', className)} {...props} />\n);\nDialogHeader.displayName = 'DialogHeader';\n\nconst DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n className={cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:gap-2', className)}\n {...props}\n />\n);\nDialogFooter.displayName = 'DialogFooter';\n\nconst DialogTitle = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Title>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n className={cn('text-lg font-semibold leading-none tracking-tight', className)}\n {...props}\n />\n));\nDialogTitle.displayName = DialogPrimitive.Title.displayName;\n\nconst DialogDescription = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Description>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n ref={ref}\n className={cn('text-sm text-fd-muted-foreground', className)}\n {...props}\n />\n));\nDialogDescription.displayName = DialogPrimitive.Description.displayName;\n\nexport {\n Dialog,\n DialogPortal,\n DialogOverlay,\n DialogClose,\n DialogTrigger,\n DialogContent,\n DialogHeader,\n DialogFooter,\n DialogTitle,\n DialogDescription,\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"dialog.js","names":[],"sources":["../../../src/ui/components/dialog.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport * as DialogPrimitive from '@radix-ui/react-dialog';\nimport { X } from 'lucide-react';\nimport { cn } from '@/utils/cn';\nimport { buttonVariants } from 'fumadocs-ui/components/ui/button';\n\nconst Dialog = DialogPrimitive.Root;\n\nconst DialogTrigger = DialogPrimitive.Trigger;\n\nconst DialogPortal = DialogPrimitive.Portal;\n\nconst DialogClose = DialogPrimitive.Close;\n\nconst DialogOverlay = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Overlay>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n className={cn(\n 'fixed inset-0 z-50 bg-black/30 backdrop-blur-sm data-[state=open]:animate-fd-fade-in data-[state=closed]:animate-fd-fade-out',\n className,\n )}\n {...props}\n />\n));\nDialogOverlay.displayName = DialogPrimitive.Overlay.displayName;\n\nconst DialogContent = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>\n>(({ className, children, ...props }, ref) => (\n <DialogPortal>\n <DialogOverlay />\n <DialogPrimitive.Content\n ref={ref}\n className={cn(\n '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-[state=open]:animate-fd-dialog-in data-[state=closed]:animate-fd-dialog-out focus-visible:outline-none',\n className,\n )}\n {...props}\n >\n {children}\n <DialogPrimitive.Close\n aria-label=\"Close\"\n className={cn(\n buttonVariants({ size: 'icon-sm', color: 'ghost' }),\n 'absolute end-2 top-2 text-fd-muted-foreground/70',\n )}\n >\n <X />\n </DialogPrimitive.Close>\n </DialogPrimitive.Content>\n </DialogPortal>\n));\nDialogContent.displayName = DialogPrimitive.Content.displayName;\n\nconst DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div className={cn('flex flex-col gap-1.5 text-center sm:text-start', className)} {...props} />\n);\nDialogHeader.displayName = 'DialogHeader';\n\nconst DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n className={cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:gap-2', className)}\n {...props}\n />\n);\nDialogFooter.displayName = 'DialogFooter';\n\nconst DialogTitle = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Title>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n className={cn('text-lg font-semibold leading-none tracking-tight', className)}\n {...props}\n />\n));\nDialogTitle.displayName = DialogPrimitive.Title.displayName;\n\nconst DialogDescription = React.forwardRef<\n React.ComponentRef<typeof DialogPrimitive.Description>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n ref={ref}\n className={cn('text-sm text-fd-muted-foreground', className)}\n {...props}\n />\n));\nDialogDescription.displayName = DialogPrimitive.Description.displayName;\n\nexport {\n Dialog,\n DialogPortal,\n DialogOverlay,\n DialogClose,\n DialogTrigger,\n DialogContent,\n DialogHeader,\n DialogFooter,\n DialogTitle,\n DialogDescription,\n};\n"],"mappings":";;;;;;;;AAQA,MAAM,SAAS,gBAAgB;AAE/B,MAAM,gBAAgB,gBAAgB;AAEtC,MAAM,eAAe,gBAAgB;AAEjB,gBAAgB;AAEpC,MAAM,gBAAgB,MAAM,YAGzB,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,gBAAgB,SAAjB;CACO;CACL,WAA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"react/jsx-runtime";
|
|
4
4
|
import { cva } from "class-variance-authority";
|
|
5
|
-
|
|
6
5
|
//#region src/ui/components/input.tsx
|
|
7
6
|
const labelVariants = cva("text-xs font-medium text-fd-foreground peer-disabled:cursor-not-allowed peer-disabled:opacity-70");
|
|
8
7
|
const Input = React.forwardRef(({ className, type, ...props }, ref) => {
|
|
@@ -14,7 +13,7 @@ const Input = React.forwardRef(({ className, type, ...props }, ref) => {
|
|
|
14
13
|
});
|
|
15
14
|
});
|
|
16
15
|
Input.displayName = "Input";
|
|
17
|
-
|
|
18
16
|
//#endregion
|
|
19
17
|
export { Input, labelVariants };
|
|
18
|
+
|
|
20
19
|
//# sourceMappingURL=input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.js","names":[],"sources":["../../../src/ui/components/input.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '@/utils/cn';\nimport { cva } from 'class-variance-authority';\n\nexport type InputProps = React.InputHTMLAttributes<HTMLInputElement>;\n\nexport const labelVariants = cva(\n 'text-xs font-medium text-fd-foreground peer-disabled:cursor-not-allowed peer-disabled:opacity-70',\n);\n\nconst Input = React.forwardRef<HTMLInputElement, InputProps>(\n ({ className, type, ...props }, ref) => {\n return (\n <input\n type={type}\n className={cn(\n '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',\n className,\n )}\n ref={ref}\n {...props}\n />\n );\n },\n);\nInput.displayName = 'Input';\n\nexport { Input };\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"input.js","names":[],"sources":["../../../src/ui/components/input.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '@/utils/cn';\nimport { cva } from 'class-variance-authority';\n\nexport type InputProps = React.InputHTMLAttributes<HTMLInputElement>;\n\nexport const labelVariants = cva(\n 'text-xs font-medium text-fd-foreground peer-disabled:cursor-not-allowed peer-disabled:opacity-70',\n);\n\nconst Input = React.forwardRef<HTMLInputElement, InputProps>(\n ({ className, type, ...props }, ref) => {\n return (\n <input\n type={type}\n className={cn(\n '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',\n className,\n )}\n ref={ref}\n {...props}\n />\n );\n },\n);\nInput.displayName = 'Input';\n\nexport { Input };\n"],"mappings":";;;;;AAMA,MAAa,gBAAgB,IAC3B,mGACD;AAED,MAAM,QAAQ,MAAM,YACjB,EAAE,WAAW,MAAM,GAAG,SAAS,QAAQ;AACtC,QACE,oBAAC,SAAD;EACQ;EACN,WAAW,GACT,iSACA,UACD;EACI;EACL,GAAI;EACJ,CAAA;EAGP;AACD,MAAM,cAAc"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { cn } from "../../utils/cn.js";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { cva } from "class-variance-authority";
|
|
4
|
-
|
|
5
4
|
//#region src/ui/components/method-label.tsx
|
|
6
5
|
const badgeVariants = cva("font-mono font-medium", { variants: { color: {
|
|
7
6
|
green: "text-green-600 dark:text-green-400",
|
|
@@ -36,7 +35,7 @@ function MethodLabel({ children, ...props }) {
|
|
|
36
35
|
children: children.toUpperCase()
|
|
37
36
|
});
|
|
38
37
|
}
|
|
39
|
-
|
|
40
38
|
//#endregion
|
|
41
39
|
export { Badge, MethodLabel };
|
|
40
|
+
|
|
42
41
|
//# sourceMappingURL=method-label.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"method-label.js","names":[],"sources":["../../../src/ui/components/method-label.tsx"],"sourcesContent":["import { cva, type VariantProps } from 'class-variance-authority';\nimport type { HTMLAttributes } from 'react';\nimport { cn } from '@/utils/cn';\n\nexport const badgeVariants = cva('font-mono font-medium', {\n variants: {\n color: {\n green: 'text-green-600 dark:text-green-400',\n yellow: 'text-yellow-600 dark:text-yellow-400',\n red: 'text-red-600 dark:text-red-400',\n blue: 'text-blue-600 dark:text-blue-400',\n orange: 'text-orange-600 dark:text-orange-400',\n },\n },\n});\n\nfunction getMethodColor(method: string): VariantProps<typeof badgeVariants>['color'] {\n switch (method.toUpperCase()) {\n case 'PUT':\n return 'yellow';\n case 'PATCH':\n return 'orange';\n case 'POST':\n return 'blue';\n case 'DELETE':\n return 'red';\n default:\n return 'green';\n }\n}\n\nexport function Badge({\n className,\n color,\n ...props\n}: Omit<HTMLAttributes<HTMLSpanElement>, 'color'> & VariantProps<typeof badgeVariants>) {\n return (\n <span\n className={cn(\n badgeVariants({\n color,\n className,\n }),\n )}\n {...props}\n >\n {props.children}\n </span>\n );\n}\n\nexport function MethodLabel({\n children,\n ...props\n}: Omit<HTMLAttributes<HTMLSpanElement>, 'children'> & {\n children: string;\n}) {\n return (\n <Badge {...props} color={getMethodColor(children)}>\n {children.toUpperCase()}\n </Badge>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"method-label.js","names":[],"sources":["../../../src/ui/components/method-label.tsx"],"sourcesContent":["import { cva, type VariantProps } from 'class-variance-authority';\nimport type { HTMLAttributes } from 'react';\nimport { cn } from '@/utils/cn';\n\nexport const badgeVariants = cva('font-mono font-medium', {\n variants: {\n color: {\n green: 'text-green-600 dark:text-green-400',\n yellow: 'text-yellow-600 dark:text-yellow-400',\n red: 'text-red-600 dark:text-red-400',\n blue: 'text-blue-600 dark:text-blue-400',\n orange: 'text-orange-600 dark:text-orange-400',\n },\n },\n});\n\nfunction getMethodColor(method: string): VariantProps<typeof badgeVariants>['color'] {\n switch (method.toUpperCase()) {\n case 'PUT':\n return 'yellow';\n case 'PATCH':\n return 'orange';\n case 'POST':\n return 'blue';\n case 'DELETE':\n return 'red';\n default:\n return 'green';\n }\n}\n\nexport function Badge({\n className,\n color,\n ...props\n}: Omit<HTMLAttributes<HTMLSpanElement>, 'color'> & VariantProps<typeof badgeVariants>) {\n return (\n <span\n className={cn(\n badgeVariants({\n color,\n className,\n }),\n )}\n {...props}\n >\n {props.children}\n </span>\n );\n}\n\nexport function MethodLabel({\n children,\n ...props\n}: Omit<HTMLAttributes<HTMLSpanElement>, 'children'> & {\n children: string;\n}) {\n return (\n <Badge {...props} color={getMethodColor(children)}>\n {children.toUpperCase()}\n </Badge>\n );\n}\n"],"mappings":";;;;AAIA,MAAa,gBAAgB,IAAI,yBAAyB,EACxD,UAAU,EACR,OAAO;CACL,OAAO;CACP,QAAQ;CACR,KAAK;CACL,MAAM;CACN,QAAQ;CACT,EACF,EACF,CAAC;AAEF,SAAS,eAAe,QAA6D;AACnF,SAAQ,OAAO,aAAa,EAA5B;EACE,KAAK,MACH,QAAO;EACT,KAAK,QACH,QAAO;EACT,KAAK,OACH,QAAO;EACT,KAAK,SACH,QAAO;EACT,QACE,QAAO;;;AAIb,SAAgB,MAAM,EACpB,WACA,OACA,GAAG,SACmF;AACtF,QACE,oBAAC,QAAD;EACE,WAAW,GACT,cAAc;GACZ;GACA;GACD,CAAC,CACH;EACD,GAAI;YAEH,MAAM;EACF,CAAA;;AAIX,SAAgB,YAAY,EAC1B,UACA,GAAG,SAGF;AACD,QACE,oBAAC,OAAD;EAAO,GAAI;EAAO,OAAO,eAAe,SAAS;YAC9C,SAAS,aAAa;EACjB,CAAA"}
|
|
@@ -3,10 +3,9 @@ import { forwardRef } from "react";
|
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { Check, ChevronDown, ChevronUp } from "lucide-react";
|
|
5
5
|
import * as SelectPrimitive from "@radix-ui/react-select";
|
|
6
|
-
|
|
7
6
|
//#region src/ui/components/select.tsx
|
|
8
7
|
const Select = SelectPrimitive.Root;
|
|
9
|
-
|
|
8
|
+
SelectPrimitive.Group;
|
|
10
9
|
const SelectValue = SelectPrimitive.Value;
|
|
11
10
|
const SelectTrigger = forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(SelectPrimitive.Trigger, {
|
|
12
11
|
ref,
|
|
@@ -69,7 +68,7 @@ const SelectSeparator = forwardRef(({ className, ...props }, ref) => /* @__PURE_
|
|
|
69
68
|
...props
|
|
70
69
|
}));
|
|
71
70
|
SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
|
|
72
|
-
|
|
73
71
|
//#endregion
|
|
74
72
|
export { Select, SelectContent, SelectItem, SelectTrigger, SelectValue };
|
|
73
|
+
|
|
75
74
|
//# sourceMappingURL=select.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.js","names":[],"sources":["../../../src/ui/components/select.tsx"],"sourcesContent":["import * as SelectPrimitive from '@radix-ui/react-select';\nimport { Check, ChevronDown, ChevronUp } from 'lucide-react';\nimport React, { forwardRef } from 'react';\nimport { cn } from '@/utils/cn';\n\nconst Select = SelectPrimitive.Root;\n\nconst SelectGroup = SelectPrimitive.Group;\n\nconst SelectValue = SelectPrimitive.Value;\n\nconst SelectTrigger = forwardRef<\n React.ComponentRef<typeof SelectPrimitive.Trigger>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>\n>(({ className, children, ...props }, ref) => (\n <SelectPrimitive.Trigger\n ref={ref}\n className={cn(\n 'flex items-center w-full rounded-md border p-2 gap-2 text-start text-sm text-fd-secondary-foreground bg-fd-secondary hover:bg-fd-accent focus:outline-none focus:ring focus:ring-fd-ring disabled:cursor-not-allowed disabled:opacity-50 data-placeholder:text-fd-muted-foreground',\n className,\n )}\n {...props}\n >\n {children}\n <SelectPrimitive.Icon asChild>\n <ChevronDown className=\"ms-auto size-3.5 text-fd-muted-foreground shrink-0\" />\n </SelectPrimitive.Icon>\n </SelectPrimitive.Trigger>\n));\nSelectTrigger.displayName = SelectPrimitive.Trigger.displayName;\n\nconst SelectScrollUpButton = forwardRef<\n React.ComponentRef<typeof SelectPrimitive.ScrollUpButton>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.ScrollUpButton\n ref={ref}\n className={cn('flex items-center justify-center py-1', className)}\n {...props}\n >\n <ChevronUp className=\"size-4\" />\n </SelectPrimitive.ScrollUpButton>\n));\nSelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;\n\nconst SelectScrollDownButton = forwardRef<\n React.ComponentRef<typeof SelectPrimitive.ScrollDownButton>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.ScrollDownButton\n ref={ref}\n className={cn('flex items-center justify-center py-1', className)}\n {...props}\n >\n <ChevronDown className=\"size-4\" />\n </SelectPrimitive.ScrollDownButton>\n));\nSelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;\n\nconst SelectContent = forwardRef<\n React.ComponentRef<typeof SelectPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>\n>(({ className, children, position, ...props }, ref) => (\n <SelectPrimitive.Portal>\n <SelectPrimitive.Content\n ref={ref}\n className={cn(\n 'z-50 overflow-hidden rounded-lg border bg-fd-popover text-fd-popover-foreground shadow-md',\n className,\n )}\n position={position}\n {...props}\n >\n <SelectScrollUpButton />\n <SelectPrimitive.Viewport className=\"p-1\">{children}</SelectPrimitive.Viewport>\n <SelectScrollDownButton />\n </SelectPrimitive.Content>\n </SelectPrimitive.Portal>\n));\nSelectContent.displayName = SelectPrimitive.Content.displayName;\n\nconst SelectLabel = forwardRef<\n React.ComponentRef<typeof SelectPrimitive.Label>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.Label\n ref={ref}\n className={cn('py-1.5 pe-2 ps-6 text-sm font-semibold', className)}\n {...props}\n />\n));\nSelectLabel.displayName = SelectPrimitive.Label.displayName;\n\nconst SelectItem = forwardRef<\n React.ComponentRef<typeof SelectPrimitive.Item>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>\n>(({ className, children, ...props }, ref) => (\n <SelectPrimitive.Item\n ref={ref}\n className={cn(\n 'flex select-none flex-row items-center rounded-md py-1.5 px-2 text-sm outline-none focus:bg-fd-accent focus:text-fd-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n className,\n )}\n {...props}\n >\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n <SelectPrimitive.ItemIndicator className=\"ms-auto\">\n <Check className=\"size-3.5 text-fd-primary\" />\n </SelectPrimitive.ItemIndicator>\n </SelectPrimitive.Item>\n));\nSelectItem.displayName = SelectPrimitive.Item.displayName;\n\nconst SelectSeparator = forwardRef<\n React.ComponentRef<typeof SelectPrimitive.Separator>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.Separator\n ref={ref}\n className={cn('my-1 h-px bg-fd-muted', className)}\n {...props}\n />\n));\nSelectSeparator.displayName = SelectPrimitive.Separator.displayName;\n\nexport {\n Select,\n SelectGroup,\n SelectValue,\n SelectTrigger,\n SelectContent,\n SelectLabel,\n SelectItem,\n SelectSeparator,\n SelectScrollUpButton,\n SelectScrollDownButton,\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"select.js","names":[],"sources":["../../../src/ui/components/select.tsx"],"sourcesContent":["import * as SelectPrimitive from '@radix-ui/react-select';\nimport { Check, ChevronDown, ChevronUp } from 'lucide-react';\nimport React, { forwardRef } from 'react';\nimport { cn } from '@/utils/cn';\n\nconst Select = SelectPrimitive.Root;\n\nconst SelectGroup = SelectPrimitive.Group;\n\nconst SelectValue = SelectPrimitive.Value;\n\nconst SelectTrigger = forwardRef<\n React.ComponentRef<typeof SelectPrimitive.Trigger>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>\n>(({ className, children, ...props }, ref) => (\n <SelectPrimitive.Trigger\n ref={ref}\n className={cn(\n 'flex items-center w-full rounded-md border p-2 gap-2 text-start text-sm text-fd-secondary-foreground bg-fd-secondary hover:bg-fd-accent focus:outline-none focus:ring focus:ring-fd-ring disabled:cursor-not-allowed disabled:opacity-50 data-placeholder:text-fd-muted-foreground',\n className,\n )}\n {...props}\n >\n {children}\n <SelectPrimitive.Icon asChild>\n <ChevronDown className=\"ms-auto size-3.5 text-fd-muted-foreground shrink-0\" />\n </SelectPrimitive.Icon>\n </SelectPrimitive.Trigger>\n));\nSelectTrigger.displayName = SelectPrimitive.Trigger.displayName;\n\nconst SelectScrollUpButton = forwardRef<\n React.ComponentRef<typeof SelectPrimitive.ScrollUpButton>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.ScrollUpButton\n ref={ref}\n className={cn('flex items-center justify-center py-1', className)}\n {...props}\n >\n <ChevronUp className=\"size-4\" />\n </SelectPrimitive.ScrollUpButton>\n));\nSelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;\n\nconst SelectScrollDownButton = forwardRef<\n React.ComponentRef<typeof SelectPrimitive.ScrollDownButton>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.ScrollDownButton\n ref={ref}\n className={cn('flex items-center justify-center py-1', className)}\n {...props}\n >\n <ChevronDown className=\"size-4\" />\n </SelectPrimitive.ScrollDownButton>\n));\nSelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;\n\nconst SelectContent = forwardRef<\n React.ComponentRef<typeof SelectPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>\n>(({ className, children, position, ...props }, ref) => (\n <SelectPrimitive.Portal>\n <SelectPrimitive.Content\n ref={ref}\n className={cn(\n 'z-50 overflow-hidden rounded-lg border bg-fd-popover text-fd-popover-foreground shadow-md',\n className,\n )}\n position={position}\n {...props}\n >\n <SelectScrollUpButton />\n <SelectPrimitive.Viewport className=\"p-1\">{children}</SelectPrimitive.Viewport>\n <SelectScrollDownButton />\n </SelectPrimitive.Content>\n </SelectPrimitive.Portal>\n));\nSelectContent.displayName = SelectPrimitive.Content.displayName;\n\nconst SelectLabel = forwardRef<\n React.ComponentRef<typeof SelectPrimitive.Label>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.Label\n ref={ref}\n className={cn('py-1.5 pe-2 ps-6 text-sm font-semibold', className)}\n {...props}\n />\n));\nSelectLabel.displayName = SelectPrimitive.Label.displayName;\n\nconst SelectItem = forwardRef<\n React.ComponentRef<typeof SelectPrimitive.Item>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>\n>(({ className, children, ...props }, ref) => (\n <SelectPrimitive.Item\n ref={ref}\n className={cn(\n 'flex select-none flex-row items-center rounded-md py-1.5 px-2 text-sm outline-none focus:bg-fd-accent focus:text-fd-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n className,\n )}\n {...props}\n >\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n <SelectPrimitive.ItemIndicator className=\"ms-auto\">\n <Check className=\"size-3.5 text-fd-primary\" />\n </SelectPrimitive.ItemIndicator>\n </SelectPrimitive.Item>\n));\nSelectItem.displayName = SelectPrimitive.Item.displayName;\n\nconst SelectSeparator = forwardRef<\n React.ComponentRef<typeof SelectPrimitive.Separator>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.Separator\n ref={ref}\n className={cn('my-1 h-px bg-fd-muted', className)}\n {...props}\n />\n));\nSelectSeparator.displayName = SelectPrimitive.Separator.displayName;\n\nexport {\n Select,\n SelectGroup,\n SelectValue,\n SelectTrigger,\n SelectContent,\n SelectLabel,\n SelectItem,\n SelectSeparator,\n SelectScrollUpButton,\n SelectScrollDownButton,\n};\n"],"m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S,QAC1B,oBAAC,gBAAgB,OAAjB;CACO;CACL,WAAW,GAAG,0CAA0C,UAAU;CAClE,GAAI;CACJ,CAAA,CACF;AACF,YAAY,cAAc,gBAAgB,MAAM;AAEhD,MAAM,aAAa,YAGhB,EAAE,WAAW,UAAU,GAAG,SAAS,QACpC,qBAAC,gBAAgB,MAAjB;CACO;CACL,WAAW,GACT,wMACA,UACD;CACD,GAAI;WANN,CAQE,oBAAC,gBAAgB,UAAjB,EAA2B,UAAoC,CAAA,EAC/D,oBAAC,gBAAgB,eAAjB;EAA+B,WAAU;YACvC,oBAAC,OAAD,EAAO,WAAU,4BAA6B,CAAA;EAChB,CAAA,CACX;GACvB;AACF,WAAW,cAAc,gBAAgB,KAAK;AAE9C,MAAM,kBAAkB,YAGrB,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,gBAAgB,WAAjB;CACO;CACL,WAAW,GAAG,yBAAyB,UAAU;CACjD,GAAI;CACJ,CAAA,CACF;AACF,gBAAgB,cAAc,gBAAgB,UAAU"}
|
package/dist/ui/contexts/api.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use client";
|
|
3
2
|
import { defaultAdapters } from "../../requests/media/adapter.js";
|
|
4
3
|
import { useStorageKey } from "../client/storage-key.js";
|
|
5
4
|
import { createCodeUsageGeneratorRegistry } from "../../requests/generators/index.js";
|
|
6
5
|
import { registerDefault } from "../../requests/generators/all.js";
|
|
7
6
|
import { createContext, use, useEffect, useMemo, useRef, useState } from "react";
|
|
8
7
|
import { jsx } from "react/jsx-runtime";
|
|
9
|
-
|
|
10
8
|
//#region src/ui/contexts/api.tsx
|
|
11
9
|
const ServerContext = createContext(null);
|
|
12
10
|
const ApiContext = createContext(null);
|
|
@@ -118,7 +116,7 @@ function getDefaultValues(server) {
|
|
|
118
116
|
for (const [k, v] of Object.entries(server.variables)) if (v.default !== void 0) out[k] = String(v.default);
|
|
119
117
|
return out;
|
|
120
118
|
}
|
|
121
|
-
|
|
122
119
|
//#endregion
|
|
123
120
|
export { ApiProvider, ServerProvider, useApiContext, useServerContext, useServerSelectContext };
|
|
121
|
+
|
|
124
122
|
//# sourceMappingURL=api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","names":[],"sources":["../../../src/ui/contexts/api.tsx"],"sourcesContent":["'use client';\nimport {\n createContext,\n type ReactNode,\n type RefObject,\n use,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport type { RenderContext, ServerObject } from '@/types';\nimport { defaultAdapters, type MediaAdapter } from '@/requests/media/adapter';\nimport type { NoReference } from '@/utils/schema';\nimport { useStorageKey } from '../client/storage-key';\nimport type { APIPageClientOptions } from '../client';\nimport {\n type CodeUsageGeneratorRegistry,\n createCodeUsageGeneratorRegistry,\n} from '@/requests/generators';\nimport { registerDefault } from '@/requests/generators/all';\n\ninterface InheritFromContext extends Pick<RenderContext, 'shikiOptions'> {\n client: APIPageClientOptions;\n}\n\nexport interface ServerProviderProps {\n /**\n * Base URL for API requests\n */\n defaultBaseUrl?: string;\n\n servers: NoReference<ServerObject>[];\n}\n\ninterface ServerContextType extends ServerProviderProps {\n /**\n * ref to selected API server (to query)\n */\n serverRef: RefObject<SelectedServer | null>;\n}\n\nconst ServerContext = createContext<ServerContextType | null>(null);\n\nexport type ApiProviderProps = InheritFromContext;\n\nexport interface SelectedServer {\n url: string;\n name?: string;\n variables: Record<string, string>;\n}\n\ninterface ApiContextType extends InheritFromContext {\n mediaAdapters: Record<string, MediaAdapter>;\n codeUsages: CodeUsageGeneratorRegistry;\n}\n\ninterface ServerSelectType {\n server: SelectedServer | null;\n setServer: (value: string) => void;\n setServerVariables: (value: Record<string, string>) => void;\n}\n\nconst ApiContext = createContext<ApiContextType | null>(null);\nconst ServerSelectContext = createContext<ServerSelectType | null>(null);\n\nexport function useApiContext(): ApiContextType {\n const ctx = use(ApiContext);\n if (!ctx) throw new Error('Component must be used under <ApiProvider />');\n\n return ctx;\n}\n\nexport function useServerContext() {\n return use(ServerContext)!;\n}\n\nexport function useServerSelectContext(): ServerSelectType {\n const ctx = use(ServerSelectContext);\n if (!ctx) throw new Error('Component must be used under <ApiProvider />');\n\n return ctx;\n}\n\nexport function ApiProvider({\n children,\n shikiOptions,\n client,\n}: ApiProviderProps & { children: ReactNode }) {\n return (\n <ApiContext\n value={useMemo(() => {\n let codeUsages: CodeUsageGeneratorRegistry;\n if (client.codeUsages) {\n codeUsages = createCodeUsageGeneratorRegistry(client.codeUsages);\n } else {\n codeUsages = createCodeUsageGeneratorRegistry();\n registerDefault(codeUsages);\n }\n\n return {\n shikiOptions,\n client,\n codeUsages,\n mediaAdapters: {\n ...defaultAdapters,\n ...client.mediaAdapters,\n },\n };\n }, [client, shikiOptions])}\n >\n {children}\n </ApiContext>\n );\n}\n\nexport function ServerProvider({\n servers,\n defaultBaseUrl,\n children,\n}: ServerProviderProps & { children: ReactNode }) {\n const serverRef = useRef<SelectedServer | null>(null);\n\n return (\n <ServerContext value={useMemo(() => ({ servers, serverRef }), [servers])}>\n <ServerSelectProvider defaultBaseUrl={defaultBaseUrl}>{children}</ServerSelectProvider>\n </ServerContext>\n );\n}\n\nfunction ServerSelectProvider({\n defaultBaseUrl,\n children,\n}: Pick<ServerProviderProps, 'defaultBaseUrl'> & {\n children: ReactNode;\n}) {\n const { servers, serverRef } = use(ServerContext)!;\n const storageKeys = useStorageKey();\n const [server, setServer] = useState<SelectedServer | null>(() => {\n const defaultItem = defaultBaseUrl\n ? servers.find((item) => item.url === defaultBaseUrl)\n : servers[0];\n\n return defaultItem\n ? {\n name: defaultItem.name,\n url: defaultItem.url!,\n variables: getDefaultValues(defaultItem),\n }\n : null;\n });\n serverRef.current = server;\n\n useEffect(() => {\n const cached = localStorage.getItem(storageKeys.of('server-url'));\n if (!cached) return;\n\n try {\n const obj: unknown = JSON.parse(cached);\n if (\n typeof obj === 'object' &&\n obj !== null &&\n 'url' in obj &&\n typeof obj.url === 'string' &&\n 'variables' in obj &&\n typeof obj.variables === 'object' &&\n obj.variables !== null\n ) {\n setServer(obj as SelectedServer);\n }\n } catch {\n // ignore\n }\n }, [storageKeys]);\n\n return (\n <ServerSelectContext\n value={useMemo(\n () => ({\n server,\n setServerVariables(variables) {\n setServer((prev) => {\n if (!prev) return null;\n\n const updated = { ...prev, variables };\n localStorage.setItem(storageKeys.of('server-url'), JSON.stringify(updated));\n return updated;\n });\n },\n setServer(value) {\n const obj = servers.find((item) => item.url === value);\n if (!obj) return;\n\n const result: SelectedServer = {\n name: obj.name,\n url: value,\n variables: getDefaultValues(obj),\n };\n\n localStorage.setItem(storageKeys.of('server-url'), JSON.stringify(result));\n setServer(result);\n },\n }),\n [server, servers, storageKeys],\n )}\n >\n {children}\n </ServerSelectContext>\n );\n}\n\nfunction getDefaultValues(server: NoReference<ServerObject>): Record<string, string> {\n const out: Record<string, string> = {};\n if (!server.variables) return out;\n\n for (const [k, v] of Object.entries(server.variables)) {\n if (v.default !== undefined) out[k] = String(v.default);\n }\n\n return out;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"api.js","names":[],"sources":["../../../src/ui/contexts/api.tsx"],"sourcesContent":["'use client';\nimport {\n createContext,\n type ReactNode,\n type RefObject,\n use,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport type { RenderContext, ServerObject } from '@/types';\nimport { defaultAdapters, type MediaAdapter } from '@/requests/media/adapter';\nimport type { NoReference } from '@/utils/schema';\nimport { useStorageKey } from '../client/storage-key';\nimport type { APIPageClientOptions } from '../client';\nimport {\n type CodeUsageGeneratorRegistry,\n createCodeUsageGeneratorRegistry,\n} from '@/requests/generators';\nimport { registerDefault } from '@/requests/generators/all';\n\ninterface InheritFromContext extends Pick<RenderContext, 'shikiOptions'> {\n client: APIPageClientOptions;\n}\n\nexport interface ServerProviderProps {\n /**\n * Base URL for API requests\n */\n defaultBaseUrl?: string;\n\n servers: NoReference<ServerObject>[];\n}\n\ninterface ServerContextType extends ServerProviderProps {\n /**\n * ref to selected API server (to query)\n */\n serverRef: RefObject<SelectedServer | null>;\n}\n\nconst ServerContext = createContext<ServerContextType | null>(null);\n\nexport type ApiProviderProps = InheritFromContext;\n\nexport interface SelectedServer {\n url: string;\n name?: string;\n variables: Record<string, string>;\n}\n\ninterface ApiContextType extends InheritFromContext {\n mediaAdapters: Record<string, MediaAdapter>;\n codeUsages: CodeUsageGeneratorRegistry;\n}\n\ninterface ServerSelectType {\n server: SelectedServer | null;\n setServer: (value: string) => void;\n setServerVariables: (value: Record<string, string>) => void;\n}\n\nconst ApiContext = createContext<ApiContextType | null>(null);\nconst ServerSelectContext = createContext<ServerSelectType | null>(null);\n\nexport function useApiContext(): ApiContextType {\n const ctx = use(ApiContext);\n if (!ctx) throw new Error('Component must be used under <ApiProvider />');\n\n return ctx;\n}\n\nexport function useServerContext() {\n return use(ServerContext)!;\n}\n\nexport function useServerSelectContext(): ServerSelectType {\n const ctx = use(ServerSelectContext);\n if (!ctx) throw new Error('Component must be used under <ApiProvider />');\n\n return ctx;\n}\n\nexport function ApiProvider({\n children,\n shikiOptions,\n client,\n}: ApiProviderProps & { children: ReactNode }) {\n return (\n <ApiContext\n value={useMemo(() => {\n let codeUsages: CodeUsageGeneratorRegistry;\n if (client.codeUsages) {\n codeUsages = createCodeUsageGeneratorRegistry(client.codeUsages);\n } else {\n codeUsages = createCodeUsageGeneratorRegistry();\n registerDefault(codeUsages);\n }\n\n return {\n shikiOptions,\n client,\n codeUsages,\n mediaAdapters: {\n ...defaultAdapters,\n ...client.mediaAdapters,\n },\n };\n }, [client, shikiOptions])}\n >\n {children}\n </ApiContext>\n );\n}\n\nexport function ServerProvider({\n servers,\n defaultBaseUrl,\n children,\n}: ServerProviderProps & { children: ReactNode }) {\n const serverRef = useRef<SelectedServer | null>(null);\n\n return (\n <ServerContext value={useMemo(() => ({ servers, serverRef }), [servers])}>\n <ServerSelectProvider defaultBaseUrl={defaultBaseUrl}>{children}</ServerSelectProvider>\n </ServerContext>\n );\n}\n\nfunction ServerSelectProvider({\n defaultBaseUrl,\n children,\n}: Pick<ServerProviderProps, 'defaultBaseUrl'> & {\n children: ReactNode;\n}) {\n const { servers, serverRef } = use(ServerContext)!;\n const storageKeys = useStorageKey();\n const [server, setServer] = useState<SelectedServer | null>(() => {\n const defaultItem = defaultBaseUrl\n ? servers.find((item) => item.url === defaultBaseUrl)\n : servers[0];\n\n return defaultItem\n ? {\n name: defaultItem.name,\n url: defaultItem.url!,\n variables: getDefaultValues(defaultItem),\n }\n : null;\n });\n serverRef.current = server;\n\n useEffect(() => {\n const cached = localStorage.getItem(storageKeys.of('server-url'));\n if (!cached) return;\n\n try {\n const obj: unknown = JSON.parse(cached);\n if (\n typeof obj === 'object' &&\n obj !== null &&\n 'url' in obj &&\n typeof obj.url === 'string' &&\n 'variables' in obj &&\n typeof obj.variables === 'object' &&\n obj.variables !== null\n ) {\n setServer(obj as SelectedServer);\n }\n } catch {\n // ignore\n }\n }, [storageKeys]);\n\n return (\n <ServerSelectContext\n value={useMemo(\n () => ({\n server,\n setServerVariables(variables) {\n setServer((prev) => {\n if (!prev) return null;\n\n const updated = { ...prev, variables };\n localStorage.setItem(storageKeys.of('server-url'), JSON.stringify(updated));\n return updated;\n });\n },\n setServer(value) {\n const obj = servers.find((item) => item.url === value);\n if (!obj) return;\n\n const result: SelectedServer = {\n name: obj.name,\n url: value,\n variables: getDefaultValues(obj),\n };\n\n localStorage.setItem(storageKeys.of('server-url'), JSON.stringify(result));\n setServer(result);\n },\n }),\n [server, servers, storageKeys],\n )}\n >\n {children}\n </ServerSelectContext>\n );\n}\n\nfunction getDefaultValues(server: NoReference<ServerObject>): Record<string, string> {\n const out: Record<string, string> = {};\n if (!server.variables) return out;\n\n for (const [k, v] of Object.entries(server.variables)) {\n if (v.default !== undefined) out[k] = String(v.default);\n }\n\n return out;\n}\n"],"mappings":";;;;;;;;AA0CA,MAAM,gBAAgB,cAAwC,KAAK;AAqBnE,MAAM,aAAa,cAAqC,KAA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
//#region src/ui/contexts/api.lazy.ts
|
|
6
4
|
const ApiProviderLazy = wrapLazy(() => import("./api.js").then((mod) => ({ default: mod.ApiProvider })));
|
|
7
5
|
const ServerProviderLazy = wrapLazy(() => import("./api.js").then((mod) => ({ default: mod.ServerProvider })));
|
|
8
|
-
|
|
9
6
|
//#endregion
|
|
10
7
|
export { ApiProviderLazy, ServerProviderLazy };
|
|
8
|
+
|
|
11
9
|
//# sourceMappingURL=api.lazy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.lazy.js","names":[],"sources":["../../../src/ui/contexts/api.lazy.ts"],"sourcesContent":["'use client';\nimport { wrapLazy } from '../../utils/lazy';\n\nexport const ApiProviderLazy = wrapLazy(() =>\n import('./api').then((mod) => ({ default: mod.ApiProvider })),\n);\n\nexport const ServerProviderLazy = wrapLazy(() =>\n import('./api').then((mod) => ({ default: mod.ServerProvider })),\n);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"api.lazy.js","names":[],"sources":["../../../src/ui/contexts/api.lazy.ts"],"sourcesContent":["'use client';\nimport { wrapLazy } from '../../utils/lazy';\n\nexport const ApiProviderLazy = wrapLazy(() =>\n import('./api').then((mod) => ({ default: mod.ApiProvider })),\n);\n\nexport const ServerProviderLazy = wrapLazy(() =>\n import('./api').then((mod) => ({ default: mod.ServerProvider })),\n);\n"],"mappings":";;;AAGA,MAAa,kBAAkB,eAC7B,OAAO,YAAS,MAAM,SAAS,EAAE,SAAS,IAAI,aAAa,EAAE,CAC9D;AAED,MAAa,qBAAqB,eAChC,OAAO,YAAS,MAAM,SAAS,EAAE,SAAS,IAAI,gBAAgB,EAAE,CACjE"}
|
package/dist/ui/full.client.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use client";
|
|
3
2
|
import { jsx } from "react/jsx-runtime";
|
|
4
3
|
import { configDefault } from "fumadocs-core/highlight";
|
|
5
4
|
import * as base from "fumadocs-core/highlight/core/client";
|
|
6
|
-
|
|
7
5
|
//#region src/ui/full.client.tsx
|
|
8
6
|
function ShikiConfigProvider({ children }) {
|
|
9
7
|
const config = base.useShikiConfigOptional() ?? configDefault;
|
|
@@ -12,7 +10,7 @@ function ShikiConfigProvider({ children }) {
|
|
|
12
10
|
children
|
|
13
11
|
});
|
|
14
12
|
}
|
|
15
|
-
|
|
16
13
|
//#endregion
|
|
17
14
|
export { ShikiConfigProvider };
|
|
15
|
+
|
|
18
16
|
//# sourceMappingURL=full.client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"full.client.js","names":[],"sources":["../../src/ui/full.client.tsx"],"sourcesContent":["'use client';\nimport * as base from 'fumadocs-core/highlight/core/client';\nimport { configDefault } from 'fumadocs-core/highlight';\nimport type { ReactNode } from 'react';\n\nexport function ShikiConfigProvider({ children }: { children: ReactNode }) {\n const config = base.useShikiConfigOptional() ?? configDefault;\n return <base.ShikiConfigProvider config={config}>{children}</base.ShikiConfigProvider>;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"full.client.js","names":[],"sources":["../../src/ui/full.client.tsx"],"sourcesContent":["'use client';\nimport * as base from 'fumadocs-core/highlight/core/client';\nimport { configDefault } from 'fumadocs-core/highlight';\nimport type { ReactNode } from 'react';\n\nexport function ShikiConfigProvider({ children }: { children: ReactNode }) {\n const config = base.useShikiConfigOptional() ?? configDefault;\n return <base.ShikiConfigProvider config={config}>{children}</base.ShikiConfigProvider>;\n}\n"],"mappings":";;;;;AAKA,SAAgB,oBAAoB,EAAE,YAAqC;CACzE,MAAM,SAAS,KAAK,wBAAwB,IAAI;AAChD,QAAO,oBAAC,KAAK,qBAAN;EAAkC;EAAS;EAAoC,CAAA"}
|
package/dist/ui/full.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { OpenAPIServer } from "../server/create.js";
|
|
2
2
|
import { ApiPageProps } from "./api-page.js";
|
|
3
|
-
import "../server/index.js";
|
|
4
3
|
import { CreateAPIPageOptions as CreateAPIPageOptions$1 } from "./base.js";
|
|
5
4
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
6
5
|
|
package/dist/ui/full.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"full.d.ts","names":[],"sources":["../../src/ui/full.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"full.d.ts","names":[],"sources":["../../src/ui/full.tsx"],"mappings":";;;;;;KAMY,oBAAA,GAAuB,OAAA,CAAQ,sBAAA;AAAA,iBAE3B,aAAA,CAAc,MAAA,EAAQ,aAAA,EAAe,OAAA,GAAS,oBAAA,IAqBhC,KAAA,EAAO,YAAA,KAAY,kBAAA,CAAA,GAAA,CAAA,OAAA"}
|
package/dist/ui/full.js
CHANGED
|
@@ -2,7 +2,6 @@ import { createAPIPage as createAPIPage$1 } from "./base.js";
|
|
|
2
2
|
import { ShikiConfigProvider } from "./full.client.js";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
import { configDefault } from "fumadocs-core/highlight";
|
|
5
|
-
|
|
6
5
|
//#region src/ui/full.tsx
|
|
7
6
|
function createAPIPage(server, options = {}) {
|
|
8
7
|
const APIPage = createAPIPage$1(server, {
|
|
@@ -27,7 +26,7 @@ function createAPIPage(server, options = {}) {
|
|
|
27
26
|
return /* @__PURE__ */ jsx(ShikiConfigProvider, { children: /* @__PURE__ */ jsx(APIPage, { ...props }) });
|
|
28
27
|
};
|
|
29
28
|
}
|
|
30
|
-
|
|
31
29
|
//#endregion
|
|
32
30
|
export { createAPIPage };
|
|
31
|
+
|
|
33
32
|
//# sourceMappingURL=full.js.map
|
package/dist/ui/full.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"full.js","names":["base.createAPIPage"],"sources":["../../src/ui/full.tsx"],"sourcesContent":["import type { OpenAPIServer } from '@/server';\nimport * as base from './base';\nimport { configDefault } from 'fumadocs-core/highlight';\nimport { ApiPageProps } from './api-page';\nimport { ShikiConfigProvider } from './full.client';\n\nexport type CreateAPIPageOptions = Partial<base.CreateAPIPageOptions>;\n\nexport function createAPIPage(server: OpenAPIServer, options: CreateAPIPageOptions = {}) {\n const APIPage = base.createAPIPage(server, {\n shiki: configDefault,\n async generateTypeScriptDefinitions(schema, ctx) {\n if (typeof schema !== 'object') return;\n const { compile } = await import('@fumari/json-schema-ts');\n\n try {\n return compile(schema, {\n name: 'Response',\n readOnly: ctx.readOnly,\n writeOnly: ctx.writeOnly,\n getSchemaId: ctx.schema.getRawRef,\n });\n } catch (e) {\n console.warn('Failed to generate typescript schema:', e);\n }\n },\n ...options,\n });\n\n return function APIPageFull(props: ApiPageProps) {\n return (\n <ShikiConfigProvider>\n <APIPage {...props} />\n </ShikiConfigProvider>\n );\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"full.js","names":["base.createAPIPage"],"sources":["../../src/ui/full.tsx"],"sourcesContent":["import type { OpenAPIServer } from '@/server';\nimport * as base from './base';\nimport { configDefault } from 'fumadocs-core/highlight';\nimport { ApiPageProps } from './api-page';\nimport { ShikiConfigProvider } from './full.client';\n\nexport type CreateAPIPageOptions = Partial<base.CreateAPIPageOptions>;\n\nexport function createAPIPage(server: OpenAPIServer, options: CreateAPIPageOptions = {}) {\n const APIPage = base.createAPIPage(server, {\n shiki: configDefault,\n async generateTypeScriptDefinitions(schema, ctx) {\n if (typeof schema !== 'object') return;\n const { compile } = await import('@fumari/json-schema-ts');\n\n try {\n return compile(schema, {\n name: 'Response',\n readOnly: ctx.readOnly,\n writeOnly: ctx.writeOnly,\n getSchemaId: ctx.schema.getRawRef,\n });\n } catch (e) {\n console.warn('Failed to generate typescript schema:', e);\n }\n },\n ...options,\n });\n\n return function APIPageFull(props: ApiPageProps) {\n return (\n <ShikiConfigProvider>\n <APIPage {...props} />\n </ShikiConfigProvider>\n );\n };\n}\n"],"mappings":";;;;;AAQA,SAAgB,cAAc,QAAuB,UAAgC,EAAE,EAAE;CACvF,MAAM,UAAUA,gBAAmB,QAAQ;EACzC,OAAO;EACP,MAAM,8BAA8B,QAAQ,KAAK;AAC/C,OAAI,OAAO,WAAW,SAAU;GAChC,MAAM,EAAE,YAAY,MAAM,OAAO;AAEjC,OAAI;AACF,WAAO,QAAQ,QAAQ;KACrB,MAAM;KACN,UAAU,IAAI;KACd,WAAW,IAAI;KACf,aAAa,IAAI,OAAO;KACzB,CAAC;YACK,GAAG;AACV,YAAQ,KAAK,yCAAyC,EAAE;;;EAG5D,GAAG;EACJ,CAAC;AAEF,QAAO,SAAS,YAAY,OAAqB;AAC/C,SACE,oBAAC,qBAAD,EAAA,UACE,oBAAC,SAAD,EAAS,GAAI,OAAS,CAAA,EACF,CAAA"}
|
package/dist/ui/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use client";
|
|
3
2
|
import { cn } from "../../utils/cn.js";
|
|
4
3
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../components/select.js";
|
|
5
4
|
import { createContext, use, useMemo, useState } from "react";
|
|
@@ -7,7 +6,6 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
7
6
|
import { Check, Copy } from "lucide-react";
|
|
8
7
|
import { buttonVariants } from "fumadocs-ui/components/ui/button";
|
|
9
8
|
import { useCopyButton } from "fumadocs-ui/utils/use-copy-button";
|
|
10
|
-
|
|
11
9
|
//#region src/ui/operation/client.tsx
|
|
12
10
|
function CopyTypeScriptPanel({ name, code, className }) {
|
|
13
11
|
const [isChecked, onCopy] = useCopyButton(() => {
|
|
@@ -69,7 +67,7 @@ function SelectTabTrigger({ items, className, ...props }) {
|
|
|
69
67
|
}, value)) })]
|
|
70
68
|
});
|
|
71
69
|
}
|
|
72
|
-
|
|
73
70
|
//#endregion
|
|
74
71
|
export { CopyTypeScriptPanel, SelectTab, SelectTabTrigger, SelectTabs };
|
|
72
|
+
|
|
75
73
|
//# sourceMappingURL=client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":[],"sources":["../../../src/ui/operation/client.tsx"],"sourcesContent":["'use client';\n\nimport { useCopyButton } from 'fumadocs-ui/utils/use-copy-button';\nimport { buttonVariants } from 'fumadocs-ui/components/ui/button';\nimport { cn } from '@/utils/cn';\nimport { Check, Copy } from 'lucide-react';\nimport { type ComponentProps, createContext, type ReactNode, use, useMemo, useState } from 'react';\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@/ui/components/select';\n\nexport function CopyTypeScriptPanel({\n name,\n code,\n className,\n}: {\n code: string;\n name: 'response body' | 'request body';\n className?: string;\n}) {\n const [isChecked, onCopy] = useCopyButton(() => {\n void navigator.clipboard.writeText(code);\n });\n\n return (\n <div\n className={cn(\n 'flex items-start justify-between gap-2 bg-fd-card text-fd-card-foreground border rounded-xl p-3 not-prose mb-4 last:mb-0',\n className,\n )}\n >\n <div>\n <p className=\"font-medium text-sm mb-2\">TypeScript Definitions</p>\n <p className=\"text-xs text-fd-muted-foreground\">Use the {name} type in TypeScript.</p>\n </div>\n <button\n onClick={onCopy}\n className={cn(\n buttonVariants({\n color: 'secondary',\n className: 'p-2 gap-2',\n size: 'sm',\n }),\n )}\n >\n {isChecked ? <Check className=\"size-3.5\" /> : <Copy className=\"size-3.5\" />}\n Copy\n </button>\n </div>\n );\n}\n\nconst Context = createContext<{\n type: string | null;\n setType: (type: string) => void;\n} | null>(null);\n\nexport function SelectTabs({\n defaultValue,\n children,\n}: {\n defaultValue?: string;\n children: ReactNode;\n}) {\n const [type, setType] = useState<string | null>(defaultValue ?? null);\n\n return <Context value={useMemo(() => ({ type, setType }), [type])}>{children}</Context>;\n}\n\nexport function SelectTab({\n value,\n ...props\n}: ComponentProps<'div'> & {\n value: string;\n}) {\n const ctx = use(Context);\n if (value !== ctx?.type) return;\n\n return <div {...props}>{props.children}</div>;\n}\n\nexport function SelectTabTrigger({\n items,\n className,\n ...props\n}: ComponentProps<typeof SelectTrigger> & {\n items: {\n label: ReactNode;\n value: string;\n }[];\n}) {\n const { type, setType } = use(Context)!;\n\n return (\n <Select value={type ?? ''} onValueChange={setType}>\n <SelectTrigger className={cn('not-prose w-fit min-w-0 *:min-w-0', className)} {...props}>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {items.map(({ label, value }) => (\n <SelectItem key={value} value={value}>\n {label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.js","names":[],"sources":["../../../src/ui/operation/client.tsx"],"sourcesContent":["'use client';\n\nimport { useCopyButton } from 'fumadocs-ui/utils/use-copy-button';\nimport { buttonVariants } from 'fumadocs-ui/components/ui/button';\nimport { cn } from '@/utils/cn';\nimport { Check, Copy } from 'lucide-react';\nimport { type ComponentProps, createContext, type ReactNode, use, useMemo, useState } from 'react';\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@/ui/components/select';\n\nexport function CopyTypeScriptPanel({\n name,\n code,\n className,\n}: {\n code: string;\n name: 'response body' | 'request body';\n className?: string;\n}) {\n const [isChecked, onCopy] = useCopyButton(() => {\n void navigator.clipboard.writeText(code);\n });\n\n return (\n <div\n className={cn(\n 'flex items-start justify-between gap-2 bg-fd-card text-fd-card-foreground border rounded-xl p-3 not-prose mb-4 last:mb-0',\n className,\n )}\n >\n <div>\n <p className=\"font-medium text-sm mb-2\">TypeScript Definitions</p>\n <p className=\"text-xs text-fd-muted-foreground\">Use the {name} type in TypeScript.</p>\n </div>\n <button\n onClick={onCopy}\n className={cn(\n buttonVariants({\n color: 'secondary',\n className: 'p-2 gap-2',\n size: 'sm',\n }),\n )}\n >\n {isChecked ? <Check className=\"size-3.5\" /> : <Copy className=\"size-3.5\" />}\n Copy\n </button>\n </div>\n );\n}\n\nconst Context = createContext<{\n type: string | null;\n setType: (type: string) => void;\n} | null>(null);\n\nexport function SelectTabs({\n defaultValue,\n children,\n}: {\n defaultValue?: string;\n children: ReactNode;\n}) {\n const [type, setType] = useState<string | null>(defaultValue ?? null);\n\n return <Context value={useMemo(() => ({ type, setType }), [type])}>{children}</Context>;\n}\n\nexport function SelectTab({\n value,\n ...props\n}: ComponentProps<'div'> & {\n value: string;\n}) {\n const ctx = use(Context);\n if (value !== ctx?.type) return;\n\n return <div {...props}>{props.children}</div>;\n}\n\nexport function SelectTabTrigger({\n items,\n className,\n ...props\n}: ComponentProps<typeof SelectTrigger> & {\n items: {\n label: ReactNode;\n value: string;\n }[];\n}) {\n const { type, setType } = use(Context)!;\n\n return (\n <Select value={type ?? ''} onValueChange={setType}>\n <SelectTrigger className={cn('not-prose w-fit min-w-0 *:min-w-0', className)} {...props}>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {items.map(({ label, value }) => (\n <SelectItem key={value} value={value}>\n {label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n );\n}\n"],"mappings":";;;;;;;;;AAeA,SAAgB,oBAAoB,EAClC,MACA,MACA,aAKC;CACD,MAAM,CAAC,WAAW,UAAU,oBAAoB;AACzC,YAAU,UAAU,UAAU,KAAK;GACxC;AAEF,QACE,qBAAC,OAAD;EACE,WAAW,GACT,4HACA,UACD;YAJH,CAME,qBAAC,OAAD,EAAA,UAAA,CACE,oBAAC,KAAD;GAAG,WAAU;aAA2B;GAA0B,CAAA,EAClE,qBAAC,KAAD;GAAG,WAAU;aAAb;IAAgD;IAAS;IAAK;IAAwB;KAClF,EAAA,CAAA,EACN,qBAAC,UAAD;GACE,SAAS;GACT,WAAW,GACT,eAAe;IACb,OAAO;IACP,WAAW;IACX,MAAM;IACP,CAAC,CACH;aARH,CAUG,YAAY,oBAAC,OAAD,EAAO,WAAU,YAAa,CAAA,GAAG,oBAAC,MAAD,EAAM,WAAU,YAAa,CAAA,EAAC,OAErE;KACL;;;AAIV,MAAM,UAAU,cAGN,KAAK;AAEf,SAAgB,WAAW,EACzB,cACA,YAIC;CACD,MAAM,CAAC,MAAM,WAAW,SAAwB,gBAAgB,KAAK;AAErE,QAAO,oBAAC,SAAD;EAAS,OAAO,eAAe;GAAE;GAAM;GAAS,GAAG,CAAC,KAAK,CAAC;EAAG;EAAmB,CAAA;;AAGzF,SAAgB,UAAU,EACxB,OACA,GAAG,SAGF;AAED,KAAI,UADQ,IAAI,QAAQ,EACL,KAAM;AAEzB,QAAO,oBAAC,OAAD;EAAK,GAAI;YAAQ,MAAM;EAAe,CAAA;;AAG/C,SAAgB,iBAAiB,EAC/B,OACA,WACA,GAAG,SAMF;CACD,MAAM,EAAE,MAAM,YAAY,IAAI,QAAQ;AAEtC,QACE,qBAAC,QAAD;EAAQ,OAAO,QAAQ;EAAI,eAAe;YAA1C,CACE,oBAAC,eAAD;GAAe,WAAW,GAAG,qCAAqC,UAAU;GAAE,GAAI;aAChF,oBAAC,aAAD,EAAe,CAAA;GACD,CAAA,EAChB,oBAAC,eAAD,EAAA,UACG,MAAM,KAAK,EAAE,OAAO,YACnB,oBAAC,YAAD;GAA+B;aAC5B;GACU,EAFI,MAEJ,CACb,EACY,CAAA,CACT"}
|
|
@@ -14,7 +14,6 @@ import { RequestTabs, getExampleRequests } from "./request-tabs.js";
|
|
|
14
14
|
import { ServerProviderLazy } from "../contexts/api.lazy.js";
|
|
15
15
|
import { Fragment } from "react";
|
|
16
16
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
17
|
-
|
|
18
17
|
//#region src/ui/operation/index.tsx
|
|
19
18
|
const ParamTypes = {
|
|
20
19
|
path: "Path Parameters",
|
|
@@ -439,7 +438,7 @@ function AuthProperty({ name, type, deprecated = false, scopes = [], className,
|
|
|
439
438
|
})]
|
|
440
439
|
});
|
|
441
440
|
}
|
|
442
|
-
|
|
443
441
|
//#endregion
|
|
444
442
|
export { Operation };
|
|
443
|
+
|
|
445
444
|
//# sourceMappingURL=index.js.map
|