apiuikit 1.6.1 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +22 -8
  2. package/dist/{CodeSamples-BJdDUuyW.cjs → CodeSamples-CE_PYa2j.cjs} +1 -1
  3. package/dist/{CodeSamples-CBNLIPmf.js → CodeSamples-D8ZHopnj.js} +1 -1
  4. package/dist/{LogoExtension-s_ImLM33.cjs → LogoExtension-BsfaM3h2.cjs} +1 -1
  5. package/dist/{LogoExtension-BnGxs1iO.js → LogoExtension-BxAoBfvv.js} +1 -1
  6. package/dist/apiuikit.cjs.js +1 -1
  7. package/dist/apiuikit.css +1 -1
  8. package/dist/apiuikit.es.js +32 -25
  9. package/dist/components/ChannelAddress.d.ts +9 -1
  10. package/dist/components/QueryParameters.d.ts +21 -0
  11. package/dist/components/Tabs.d.ts +21 -2
  12. package/dist/containers/AsyncAPI/AsyncAPI.d.ts +3 -0
  13. package/dist/containers/AsyncAPI/AsyncAPIDocumentProvider.d.ts +4 -1
  14. package/dist/containers/AsyncAPI/AsyncAPIRenderer.d.ts +4 -1
  15. package/dist/containers/AsyncAPI/Layout.d.ts +3 -1
  16. package/dist/containers/OpenAPI/Layout.d.ts +3 -1
  17. package/dist/containers/OpenAPI/OpenAPI.d.ts +3 -0
  18. package/dist/containers/OpenAPI/OpenAPIDocumentProvider.d.ts +4 -1
  19. package/dist/containers/OpenAPI/OpenAPIRenderer.d.ts +4 -1
  20. package/dist/contexts/useSpec.d.ts +15 -1
  21. package/dist/hooks/useDocumentProviderValue.d.ts +5 -1
  22. package/dist/index-BG2MGxhP.cjs +180 -0
  23. package/dist/{index-Nbf5MZiI.cjs → index-C4dsAuGH.cjs} +1 -1
  24. package/dist/{index-C8hbyW3W.cjs → index-CXAGho9r.cjs} +1 -1
  25. package/dist/{index-BeUvL__Z.js → index-CXSFEEqv.js} +1 -1
  26. package/dist/{index-mTesjc4t.js → index-DGGpf1hd.js} +1 -1
  27. package/dist/{index-CcMtyrpk.js → index-mzpFFTrv.js} +5518 -5153
  28. package/dist/index.d.ts +10 -5
  29. package/dist/plugin.cjs +1 -0
  30. package/dist/plugin.d.ts +7 -0
  31. package/dist/plugin.es.js +14 -0
  32. package/dist/plugins/OperationPluginTabs.d.ts +13 -0
  33. package/dist/plugins/PluginSlot.d.ts +44 -0
  34. package/dist/plugins/registry.d.ts +7 -0
  35. package/dist/plugins/types.d.ts +84 -0
  36. package/dist/{protoToJsonSchema-BXXNt4lb.js → protoToJsonSchema-Bz9yIjAo.js} +1 -1
  37. package/dist/{protoToJsonSchema-BcZ8ZAVF.cjs → protoToJsonSchema-DjrQ6cDd.cjs} +1 -1
  38. package/dist/{protobufSchemaParser-DDcdjpqs.cjs → protobufSchemaParser-BDvHrzAl.cjs} +1 -1
  39. package/dist/{protobufSchemaParser-SgaIKKy_.js → protobufSchemaParser-CaWUT6i7.js} +2 -2
  40. package/dist/public/createSectionRoot.d.ts +5 -1
  41. package/dist/public/openapiSections.d.ts +7 -2
  42. package/dist/public/schemasSection.d.ts +34 -0
  43. package/dist/public/sections.d.ts +7 -2
  44. package/dist/utils/anchorLayer.d.ts +35 -0
  45. package/package.json +7 -2
  46. package/dist/index-DZLN6OIH.cjs +0 -180
@@ -1,4 +1,4 @@
1
- import { ComponentType } from 'react';
1
+ import { ComponentType, ReactNode } from 'react';
2
2
  export type Tab = {
3
3
  id: string;
4
4
  name: string;
@@ -12,8 +12,27 @@ interface TabsProps {
12
12
  onChange?: (id: string) => void;
13
13
  ariaLabel?: string;
14
14
  selectLabel?: string;
15
+ /** Scopes the tab and panel DOM ids when more than one tab list can appear on a page. */
16
+ idPrefix?: string;
15
17
  /** When set, the mobile `<select>` includes an empty option for no selection. */
16
18
  placeholder?: string;
19
+ /**
20
+ * `"segmented"` renders a compact, content-width pill toggle (small text,
21
+ * tight padding, active tab picked out with a light background) instead of
22
+ * the default full-width strip — for a control that switches *which panel
23
+ * you're looking at* rather than one that reads as a section of the page's
24
+ * own navigation. Omit to keep the existing icon/no-icon inference.
25
+ */
26
+ variant?: "segmented";
17
27
  }
18
- export default function Tabs({ tabs, current, onChange, ariaLabel, selectLabel, placeholder, }: TabsProps): import("react").JSX.Element | null;
28
+ export default function Tabs({ tabs, current, onChange, ariaLabel, selectLabel, idPrefix, placeholder, variant, }: TabsProps): import("react").JSX.Element | null;
29
+ interface TabPanelsProps {
30
+ tabs: Tab[];
31
+ current: string;
32
+ idPrefix?: string;
33
+ renderPanel: (tab: Tab, active: boolean) => ReactNode;
34
+ }
35
+ /** Renders one linked ARIA panel per tab. The caller decides which panels
36
+ * have mounted content, allowing visited panels to remain stateful. */
37
+ export declare function TabPanels({ tabs, current, idPrefix, renderPanel }: TabPanelsProps): import("react").JSX.Element;
19
38
  export {};
@@ -2,11 +2,14 @@ import { ConfigInterface } from '../../config';
2
2
  import { AsyncAPIDocumentData } from '../../types/schema';
3
3
  import { ErrorBoundaryFallbackRenderer } from '../../components/ErrorBoundary';
4
4
  import { ErrorInfo, ReactNode } from 'react';
5
+ import { ApiuikitPlugin } from '../../plugins/types';
5
6
  export interface IAsyncAPIProps {
6
7
  /** A pre-resolved AsyncAPI 3.0 document object, or one that still contains `$ref`s. */
7
8
  asyncapi: AsyncAPIDocumentData;
8
9
  /** UI configuration: theme, which sections to show, sidebar options, and more. */
9
10
  config?: ConfigInterface;
11
+ /** Third-party plugins (e.g. a "try it out" panel) to render into this document's extension slots. */
12
+ plugins?: ApiuikitPlugin[];
10
13
  /** Promise that `asyncapi` is already fully dereferenced upstream. Verified rather than trusted: `$ref`s left in place are still resolved either way, with a console warning that the promise was false. */
11
14
  kind?: "resolved";
12
15
  /** Custom UI shown if rendering this document throws. Defaults to a built-in fallback. */
@@ -1,12 +1,15 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { ConfigInterface } from '../../config';
3
3
  import { AsyncAPIDocumentData } from '../../types/schema';
4
+ import { ApiuikitPlugin } from '../../plugins/types';
4
5
  export interface AsyncAPIDocumentProviderProps {
5
6
  document: AsyncAPIDocumentData;
6
7
  config?: ConfigInterface;
8
+ /** Third-party plugins to register on this document's context. */
9
+ plugins?: ApiuikitPlugin[];
7
10
  /** Extra classes merged onto the root surface. */
8
11
  className?: string;
9
12
  children: ReactNode;
10
13
  }
11
- export declare function AsyncAPIDocumentProvider({ document: asyncapi, config, className, children, }: AsyncAPIDocumentProviderProps): import("react").JSX.Element;
14
+ export declare function AsyncAPIDocumentProvider({ document: asyncapi, config, plugins, className, children, }: AsyncAPIDocumentProviderProps): import("react").JSX.Element;
12
15
  export default AsyncAPIDocumentProvider;
@@ -1,11 +1,14 @@
1
1
  import { ConfigInterface } from '../../config/config';
2
2
  import { ErrorBoundaryFallbackRenderer } from '../../components/ErrorBoundary';
3
3
  import { ErrorInfo, ReactNode } from 'react';
4
+ import { ApiuikitPlugin } from '../../plugins/types';
4
5
  interface AsyncAPIRendererProps {
5
6
  /** Raw AsyncAPI document as a YAML or JSON string, parsed and validated internally via `@asyncapi/parser`. */
6
7
  raw: string;
7
8
  /** UI configuration: theme, which sections to show, sidebar options, and more. */
8
9
  config?: ConfigInterface;
10
+ /** Third-party plugins (e.g. a "try it out" panel) to render into this document's extension slots. */
11
+ plugins?: ApiuikitPlugin[];
9
12
  /** Called with the parser's diagnostics (errors/warnings) after each parse attempt. */
10
13
  onDiagnostics?: (diagnostics: unknown[]) => void;
11
14
  /** Custom UI shown if rendering the parsed document throws. Defaults to a built-in fallback. */
@@ -19,5 +22,5 @@ interface AsyncAPIRendererProps {
19
22
  * document as text rather than a pre-parsed object, e.g. user-entered or
20
23
  * loaded from a file at runtime.
21
24
  */
22
- export declare function AsyncAPIRenderer({ raw, config, onDiagnostics, errorFallback, onError }: AsyncAPIRendererProps): import("react").JSX.Element | null;
25
+ export declare function AsyncAPIRenderer({ raw, config, plugins, onDiagnostics, errorFallback, onError }: AsyncAPIRendererProps): import("react").JSX.Element | null;
23
26
  export {};
@@ -1,7 +1,9 @@
1
1
  import { ConfigInterface } from '../../config';
2
+ import { ApiuikitPlugin } from '../../plugins/types';
2
3
  import { AsyncAPIDocumentData } from '../../types/schema';
3
4
  export interface LayoutProps {
4
5
  asyncapi: AsyncAPIDocumentData;
5
6
  config: ConfigInterface;
7
+ plugins?: ApiuikitPlugin[];
6
8
  }
7
- export default function Layout({ asyncapi, config }: LayoutProps): import("react").JSX.Element;
9
+ export default function Layout({ asyncapi, config, plugins }: LayoutProps): import("react").JSX.Element;
@@ -1,7 +1,9 @@
1
1
  import { ConfigInterface } from '../../config';
2
+ import { ApiuikitPlugin } from '../../plugins/types';
2
3
  import { OpenAPIDocumentData } from '../../types/openapi';
3
4
  export interface OpenAPILayoutProps {
4
5
  openapi: OpenAPIDocumentData;
5
6
  config: ConfigInterface;
7
+ plugins?: ApiuikitPlugin[];
6
8
  }
7
- export default function Layout({ openapi, config }: OpenAPILayoutProps): import("react").JSX.Element;
9
+ export default function Layout({ openapi, config, plugins }: OpenAPILayoutProps): import("react").JSX.Element;
@@ -2,11 +2,14 @@ import { ConfigInterface } from '../../config';
2
2
  import { OpenAPIDocumentData } from '../../types/openapi';
3
3
  import { ErrorBoundaryFallbackRenderer } from '../../components/ErrorBoundary';
4
4
  import { ErrorInfo, ReactNode } from 'react';
5
+ import { ApiuikitPlugin } from '../../plugins/types';
5
6
  export interface IOpenAPIProps {
6
7
  /** A pre-resolved OpenAPI 3.0/3.1 document object, or one that still contains `$ref`s. */
7
8
  openapi: OpenAPIDocumentData;
8
9
  /** UI configuration: theme, which sections to show, sidebar options, and more. */
9
10
  config?: ConfigInterface;
11
+ /** Third-party plugins (e.g. a "try it out" panel) to render into this document's extension slots. */
12
+ plugins?: ApiuikitPlugin[];
10
13
  /** Promise that `openapi` is already fully dereferenced upstream. Verified rather than trusted: `$ref`s left in place are still resolved either way, with a console warning that the promise was false. */
11
14
  kind?: "resolved";
12
15
  /** Custom UI shown if rendering this document throws. Defaults to a built-in fallback. */
@@ -1,13 +1,16 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { ConfigInterface } from '../../config';
3
3
  import { OpenAPIDocumentData } from '../../types/openapi';
4
+ import { ApiuikitPlugin } from '../../plugins/types';
4
5
  export interface OpenAPIDocumentProviderProps {
5
6
  document: OpenAPIDocumentData;
6
7
  config?: ConfigInterface;
8
+ /** Third-party plugins to register on this document's context. */
9
+ plugins?: ApiuikitPlugin[];
7
10
  /** Extra classes merged onto the root surface. */
8
11
  className?: string;
9
12
  children: ReactNode;
10
13
  }
11
14
  /** Mirrors AsyncAPIDocumentProvider, sharing the same DocumentContext shape. */
12
- export declare function OpenAPIDocumentProvider({ document: openapi, config, className, children, }: OpenAPIDocumentProviderProps): import("react").JSX.Element;
15
+ export declare function OpenAPIDocumentProvider({ document: openapi, config, plugins, className, children, }: OpenAPIDocumentProviderProps): import("react").JSX.Element;
13
16
  export default OpenAPIDocumentProvider;
@@ -1,11 +1,14 @@
1
1
  import { ConfigInterface } from '../../config/config';
2
2
  import { ErrorBoundaryFallbackRenderer } from '../../components/ErrorBoundary';
3
3
  import { ErrorInfo, ReactNode } from 'react';
4
+ import { ApiuikitPlugin } from '../../plugins/types';
4
5
  interface OpenAPIRendererProps {
5
6
  /** Raw OpenAPI document as a YAML or JSON string, parsed and validated internally via `@readme/openapi-parser`. */
6
7
  raw: string;
7
8
  /** UI configuration: theme, which sections to show, sidebar options, and more. */
8
9
  config?: ConfigInterface;
10
+ /** Third-party plugins (e.g. a "try it out" panel) to render into this document's extension slots. */
11
+ plugins?: ApiuikitPlugin[];
9
12
  /** Called with the parser's diagnostics (errors/warnings) after each parse attempt. */
10
13
  onDiagnostics?: (diagnostics: unknown[]) => void;
11
14
  /** Custom UI shown if rendering the parsed document throws. Defaults to a built-in fallback. */
@@ -19,5 +22,5 @@ interface OpenAPIRendererProps {
19
22
  * have a document as text rather than a pre-parsed object, e.g. user-entered
20
23
  * or loaded from a file at runtime.
21
24
  */
22
- export declare function OpenAPIRenderer({ raw, config, onDiagnostics, errorFallback, onError }: OpenAPIRendererProps): import("react").JSX.Element | null;
25
+ export declare function OpenAPIRenderer({ raw, config, plugins, onDiagnostics, errorFallback, onError }: OpenAPIRendererProps): import("react").JSX.Element | null;
23
26
  export {};
@@ -1,6 +1,8 @@
1
1
  import { AsyncAPIDocumentData } from '../types/schema';
2
2
  import { OpenAPIDocumentData } from '../types/openapi';
3
- import { MarkdownUrlResolver, SidePanelContainment } from '../config/config';
3
+ import { ConfigInterface, MarkdownUrlResolver, SidePanelContainment } from '../config/config';
4
+ import { ApiuikitPlugin } from '../plugins/types';
5
+ import { PluginSlotRegistry } from '../plugins/registry';
4
6
  /** Which spec produced the ambient document. The discriminant of DocumentContextValue. */
5
7
  export type SpecType = "asyncapi" | "openapi";
6
8
  interface DocumentContextBase {
@@ -25,6 +27,12 @@ interface DocumentContextBase {
25
27
  showCodeSamples: boolean;
26
28
  /** Resolves the hosted URL serving a target as Markdown, if the consumer serves one (config.markdown.url). */
27
29
  markdownUrl?: MarkdownUrlResolver;
30
+ /** Third-party plugins registered on the nearest `<AsyncAPI>`/`<OpenAPI>` (or provider), consumed via `PluginSlot`. Undefined is equivalent to none registered. */
31
+ plugins?: ApiuikitPlugin[];
32
+ /** Pre-indexed plugin fills used internally by slot hosts. */
33
+ pluginSlotRegistry?: PluginSlotRegistry;
34
+ /** The host's as-given `config` prop, unmerged with defaults. For plugins; prefer the derived fields above for apiuikit's own UI. Theme colors: use the CSS custom properties on the document root (see Plugins docs), not `config.theme`. */
35
+ config?: ConfigInterface;
28
36
  }
29
37
  export interface AsyncAPIDocumentContextValue extends DocumentContextBase {
30
38
  specType: "asyncapi";
@@ -44,6 +52,12 @@ export interface OpenAPIDocumentContextValue extends DocumentContextBase {
44
52
  export type DocumentContextValue = AsyncAPIDocumentContextValue | OpenAPIDocumentContextValue;
45
53
  export declare const DocumentContext: import('react').Context<DocumentContextValue | null>;
46
54
  export declare const useDocumentContext: () => DocumentContextValue;
55
+ /** Returns an AsyncAPI context and fails fast when rendered under the wrong
56
+ * document provider. */
57
+ export declare const useAsyncAPIDocumentContext: () => AsyncAPIDocumentContextValue;
58
+ /** Returns an OpenAPI context and fails fast when rendered under the wrong
59
+ * document provider. */
60
+ export declare const useOpenAPIDocumentContext: () => OpenAPIDocumentContextValue;
47
61
  export declare const AsyncAPIDocumentContext: import('react').Context<DocumentContextValue | null>;
48
62
  export declare const useAsyncAPIDocument: () => DocumentContextValue;
49
63
  export {};
@@ -1,6 +1,7 @@
1
1
  import { ConfigInterface } from '../config';
2
2
  import { MarkdownUrlResolver, SidePanelContainment } from '../config/config';
3
3
  import { SpecType } from '../contexts';
4
+ import { ApiuikitPlugin } from '../plugins/types';
4
5
  /**
5
6
  * Builds the shared DocumentContext value (deref resolver, portal/root refs,
6
7
  * theme-derived settings) plus the CSS custom properties for the theme,
@@ -10,7 +11,7 @@ import { SpecType } from '../contexts';
10
11
  * `specType` and document type, and thus lands as the right member of the
11
12
  * DocumentContextValue union.
12
13
  */
13
- export declare function useDocumentProviderValue<S extends SpecType, D extends object>(specType: S, document: D, config?: ConfigInterface): {
14
+ export declare function useDocumentProviderValue<S extends SpecType, D extends object>(specType: S, document: D, config?: ConfigInterface, plugins?: ApiuikitPlugin[]): {
14
15
  contextValue: {
15
16
  specType: S;
16
17
  document: D;
@@ -25,6 +26,9 @@ export declare function useDocumentProviderValue<S extends SpecType, D extends o
25
26
  showExtensions: boolean;
26
27
  showCodeSamples: boolean;
27
28
  markdownUrl: MarkdownUrlResolver | undefined;
29
+ plugins: ApiuikitPlugin[];
30
+ pluginSlotRegistry: import('../plugins/registry').PluginSlotRegistry;
31
+ config: ConfigInterface;
28
32
  };
29
33
  themeVars: Record<string, string>;
30
34
  setPortalHost: import('react').Dispatch<import('react').SetStateAction<HTMLDivElement | null>>;