apiuikit 0.2.1 → 0.3.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 (58) hide show
  1. package/dist/apiuikit.cjs.js +1 -1
  2. package/dist/apiuikit.css +1 -1
  3. package/dist/apiuikit.es.js +16 -9
  4. package/dist/components/Bindings.d.ts +3 -1
  5. package/dist/components/Navigation.d.ts +11 -4
  6. package/dist/components/SearchPanel.d.ts +9 -0
  7. package/dist/components/schema/SchemaNode.d.ts +10 -1
  8. package/dist/components/schema/SchemaTab.d.ts +3 -1
  9. package/dist/components/schema/SchemaTree.d.ts +5 -1
  10. package/dist/components/schema/SchemaTreeRow.d.ts +2 -1
  11. package/dist/config/config.d.ts +1 -0
  12. package/dist/containers/AsyncAPI/AsyncAPIDocumentProvider.d.ts +12 -0
  13. package/dist/containers/AsyncAPI/tests/searchHighlight.test.d.ts +1 -0
  14. package/dist/containers/Messages/MessageDetails.d.ts +3 -1
  15. package/dist/containers/Messages/Messages.d.ts +3 -1
  16. package/dist/containers/Operation/Operation.d.ts +3 -1
  17. package/dist/containers/Operation/Operations.d.ts +3 -1
  18. package/dist/containers/Schema/Schemas.d.ts +6 -1
  19. package/dist/containers/Server/Server.d.ts +8 -1
  20. package/dist/containers/Server/Servers.d.ts +7 -3
  21. package/dist/helpers/protobuf/lazyProtoToJsonSchema.d.ts +14 -0
  22. package/dist/helpers/schemaFormat.d.ts +3 -0
  23. package/dist/helpers/searchIndex.d.ts +18 -0
  24. package/dist/helpers/textHighlight.d.ts +2 -0
  25. package/dist/hooks/useSpecSearch.d.ts +13 -0
  26. package/dist/icons/Server.d.ts +4 -3
  27. package/dist/index-Bad1aEIj.js +11352 -0
  28. package/dist/{index-yG3rYT_D.js → index-CzcxQGxP.js} +1 -1
  29. package/dist/{index-DqcOEYz_.cjs → index-D7GelPk0.cjs} +1 -1
  30. package/dist/index-gn5KpvCL.cjs +73 -0
  31. package/dist/index.d.ts +2 -0
  32. package/dist/protoToJsonSchema-8Mm10CIx.cjs +83 -0
  33. package/dist/protoToJsonSchema-BJpwl2Am.js +6174 -0
  34. package/dist/protobufSchemaParser-Cj2WOp05.js +55 -0
  35. package/dist/protobufSchemaParser-D_2rEsD4.cjs +1 -0
  36. package/dist/public/sections.d.ts +42 -0
  37. package/dist/public/tests/sections.test.d.ts +1 -0
  38. package/dist/stories/Authorization.stories.d.ts +13 -0
  39. package/dist/stories/Bindings.stories.d.ts +12 -0
  40. package/dist/stories/ChannelAddress.stories.d.ts +13 -0
  41. package/dist/stories/CodeBlock.stories.d.ts +11 -0
  42. package/dist/stories/Examples.stories.d.ts +11 -0
  43. package/dist/stories/Information.stories.d.ts +1 -0
  44. package/dist/stories/Message.stories.d.ts +11 -0
  45. package/dist/stories/Messages.stories.d.ts +10 -0
  46. package/dist/stories/Operation.stories.d.ts +10 -0
  47. package/dist/stories/Operations.stories.d.ts +10 -0
  48. package/dist/stories/SchemaTab.stories.d.ts +11 -0
  49. package/dist/stories/SearchPanel.stories.d.ts +16 -0
  50. package/dist/stories/Server.stories.d.ts +3 -1
  51. package/dist/stories/TabToggle.stories.d.ts +10 -0
  52. package/dist/stories/Tabs.stories.d.ts +11 -0
  53. package/dist/stories/documentContextDecorator.d.ts +25 -0
  54. package/package.json +2 -3
  55. package/dist/index-BYmrdiVi.cjs +0 -155
  56. package/dist/index-DfH4J5EL.js +0 -15436
  57. package/dist/stories/Button.d.ts +0 -14
  58. package/dist/stories/Button.stories.d.ts +0 -23
@@ -0,0 +1,55 @@
1
+ import { protoToJsonSchema as e } from "./protoToJsonSchema-BJpwl2Am.js";
2
+ import { r as a, i as s, X as t } from "./index-Bad1aEIj.js";
3
+ function n(r) {
4
+ if (typeof r != "string")
5
+ return ["Protobuf schema must be a string of .proto source"];
6
+ try {
7
+ return e(r), [];
8
+ } catch (o) {
9
+ return [
10
+ o instanceof Error ? o.message : "Failed to parse protobuf schema"
11
+ ];
12
+ }
13
+ }
14
+ const c = [
15
+ "application/vnd.google.protobuf",
16
+ "application/vnd.google.protobuf;version=2",
17
+ "application/vnd.google.protobuf;version=3"
18
+ ];
19
+ function i() {
20
+ return {
21
+ validate: u,
22
+ parse: f,
23
+ getMimeTypes: () => c
24
+ };
25
+ }
26
+ function g(r) {
27
+ a(
28
+ r,
29
+ i(),
30
+ s
31
+ );
32
+ }
33
+ function u(r) {
34
+ return n(r.data).map((o) => ({
35
+ message: o,
36
+ path: r.path
37
+ }));
38
+ }
39
+ function f(r) {
40
+ if (typeof r.data != "string")
41
+ return {
42
+ [t]: "Protobuf schema must be a string of .proto source"
43
+ };
44
+ try {
45
+ return e(r.data);
46
+ } catch (o) {
47
+ return {
48
+ [t]: o instanceof Error ? o.message : "Failed to convert Protobuf schema"
49
+ };
50
+ }
51
+ }
52
+ export {
53
+ i as ProtobufSchemaParser,
54
+ g as registerProtobufSchemaParser
55
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./protoToJsonSchema-8Mm10CIx.cjs"),e=require("./index-gn5KpvCL.cjs");function n(r){if(typeof r!="string")return["Protobuf schema must be a string of .proto source"];try{return t.protoToJsonSchema(r),[]}catch(o){return[o instanceof Error?o.message:"Failed to parse protobuf schema"]}}const s=["application/vnd.google.protobuf","application/vnd.google.protobuf;version=2","application/vnd.google.protobuf;version=3"];function a(){return{validate:u,parse:i,getMimeTypes:()=>s}}function c(r){e.registerSchemaParserWithFallback(r,a(),e.isProtobufSchemaFormat)}function u(r){return n(r.data).map(o=>({message:o,path:r.path}))}function i(r){if(typeof r.data!="string")return{[e.X_LIB_CONVERSION_ERROR]:"Protobuf schema must be a string of .proto source"};try{return t.protoToJsonSchema(r.data)}catch(o){return{[e.X_LIB_CONVERSION_ERROR]:o instanceof Error?o.message:"Failed to convert Protobuf schema"}}}exports.ProtobufSchemaParser=a;exports.registerProtobufSchemaParser=c;
@@ -0,0 +1,42 @@
1
+ import { ReactNode } from 'react';
2
+ import { ConfigInterface } from '../config';
3
+ import { AsyncAPIDocumentData } from '../types/schema';
4
+ /**
5
+ * Standalone, composable section components. Each renders one part of an
6
+ * AsyncAPI document (servers, operations, messages, schemas, info) on its own,
7
+ * so consumers can arrange them in their own layout instead of using the whole
8
+ * `<AsyncAPI>` widget.
9
+ *
10
+ * They're dual-mode:
11
+ * - Standalone — pass a `document` (and optional `config`); the section
12
+ * resolves it and sets up its own context.
13
+ * <Operations document={doc} />
14
+ * - Composed — render several under one <AsyncAPIProvider> (resolves once,
15
+ * shares context); sections then read from it and their own `document`
16
+ * prop is unnecessary.
17
+ * <AsyncAPIProvider document={doc}>
18
+ * <Servers /> <Operations />
19
+ * </AsyncAPIProvider>
20
+ */
21
+ export interface SectionProps {
22
+ /** The AsyncAPI document. Required standalone; unnecessary (and ignored)
23
+ * when rendered inside <AsyncAPIProvider> or <AsyncAPI>. */
24
+ document?: AsyncAPIDocumentData;
25
+ /** Only applied when this section sets up its own context (standalone). When
26
+ * composed under a provider, config comes from that provider. */
27
+ config?: ConfigInterface;
28
+ }
29
+ /**
30
+ * Provider that resolves a document once and shares it with any section
31
+ * components rendered inside — the composition entry point.
32
+ */
33
+ export declare function AsyncAPIProvider({ document, config, children, }: {
34
+ document: AsyncAPIDocumentData;
35
+ config?: ConfigInterface;
36
+ children: ReactNode;
37
+ }): import("react").JSX.Element;
38
+ export declare function Servers(props: SectionProps): import("react").JSX.Element;
39
+ export declare function Operations(props: SectionProps): import("react").JSX.Element;
40
+ export declare function Messages(props: SectionProps): import("react").JSX.Element;
41
+ export declare function Schemas(props: SectionProps): import("react").JSX.Element;
42
+ export declare function Info(props: SectionProps): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import { StoryObj } from '@storybook/react';
2
+ import { default as Authorization } from '../components/Authorization';
3
+ declare const meta: {
4
+ title: string;
5
+ component: typeof Authorization;
6
+ decorators: ((Story: import('react').ComponentType) => import("react").JSX.Element)[];
7
+ };
8
+ export default meta;
9
+ type Story = StoryObj<typeof meta>;
10
+ export declare const MultipleSchemes: Story;
11
+ export declare const OAuth2: Story;
12
+ export declare const ApiKey: Story;
13
+ export declare const OpenIdConnect: Story;
@@ -0,0 +1,12 @@
1
+ import { StoryObj } from '@storybook/react';
2
+ import { default as Bindings } from '../components/Bindings';
3
+ declare const meta: {
4
+ title: string;
5
+ component: typeof Bindings;
6
+ decorators: ((Story: import('react').ComponentType) => import("react").JSX.Element)[];
7
+ };
8
+ export default meta;
9
+ type Story = StoryObj<typeof meta>;
10
+ export declare const KafkaServer: Story;
11
+ export declare const KafkaOperation: Story;
12
+ export declare const Collapsed: Story;
@@ -0,0 +1,13 @@
1
+ import { ComponentType } from 'react';
2
+ import { StoryObj } from '@storybook/react';
3
+ import { ChannelAddress } from '../components/ChannelAddress';
4
+ declare const meta: {
5
+ title: string;
6
+ component: typeof ChannelAddress;
7
+ decorators: ((Story: ComponentType) => import("react").JSX.Element)[];
8
+ };
9
+ export default meta;
10
+ type Story = StoryObj<typeof meta>;
11
+ export declare const WithParameters: Story;
12
+ export declare const Plain: Story;
13
+ export declare const Truncated: Story;
@@ -0,0 +1,11 @@
1
+ import { StoryObj } from '@storybook/react';
2
+ import { CodeBlock } from '../components/CodeBlock';
3
+ declare const meta: {
4
+ title: string;
5
+ component: typeof CodeBlock;
6
+ decorators: ((Story: import('react').ComponentType) => import("react").JSX.Element)[];
7
+ };
8
+ export default meta;
9
+ type Story = StoryObj<typeof meta>;
10
+ export declare const Default: Story;
11
+ export declare const ShortSnippet: Story;
@@ -0,0 +1,11 @@
1
+ import { StoryObj } from '@storybook/react';
2
+ import { Examples } from '../components/Examples';
3
+ declare const meta: {
4
+ title: string;
5
+ component: typeof Examples;
6
+ decorators: ((Story: import('react').ComponentType) => import("react").JSX.Element)[];
7
+ };
8
+ export default meta;
9
+ type Story = StoryObj<typeof meta>;
10
+ export declare const Default: Story;
11
+ export declare const WithEnumAndExamples: Story;
@@ -2,6 +2,7 @@ import { StoryObj } from '@storybook/react';
2
2
  declare const meta: {
3
3
  title: string;
4
4
  component: import('react').FunctionComponent<import('../types/asyncapi/Info').Info>;
5
+ decorators: ((Story: import('react').ComponentType) => import("react").JSX.Element)[];
5
6
  };
6
7
  export default meta;
7
8
  type Story = StoryObj<typeof meta>;
@@ -0,0 +1,11 @@
1
+ import { StoryObj } from '@storybook/react';
2
+ import { Message } from '../containers/Messages/Message';
3
+ declare const meta: {
4
+ title: string;
5
+ component: typeof Message;
6
+ decorators: ((Story: import('react').ComponentType) => import("react").JSX.Element)[];
7
+ };
8
+ export default meta;
9
+ type Story = StoryObj<typeof meta>;
10
+ export declare const Default: Story;
11
+ export declare const Expanded: Story;
@@ -0,0 +1,10 @@
1
+ import { StoryObj } from '@storybook/react';
2
+ import { Messages } from '../public/sections';
3
+ declare const meta: {
4
+ title: string;
5
+ component: typeof Messages;
6
+ decorators: ((Story: import('react').ComponentType) => import("react").JSX.Element)[];
7
+ };
8
+ export default meta;
9
+ type Story = StoryObj<typeof meta>;
10
+ export declare const Default: Story;
@@ -0,0 +1,10 @@
1
+ import { StoryObj } from '@storybook/react';
2
+ import { default as Operation } from '../containers/Operation/Operation';
3
+ declare const meta: {
4
+ title: string;
5
+ component: typeof Operation;
6
+ decorators: ((Story: import('react').ComponentType) => import("react").JSX.Element)[];
7
+ };
8
+ export default meta;
9
+ type Story = StoryObj<typeof meta>;
10
+ export declare const Default: Story;
@@ -0,0 +1,10 @@
1
+ import { StoryObj } from '@storybook/react';
2
+ import { Operations } from '../public/sections';
3
+ declare const meta: {
4
+ title: string;
5
+ component: typeof Operations;
6
+ decorators: ((Story: import('react').ComponentType) => import("react").JSX.Element)[];
7
+ };
8
+ export default meta;
9
+ type Story = StoryObj<typeof meta>;
10
+ export declare const Default: Story;
@@ -0,0 +1,11 @@
1
+ import { StoryObj } from '@storybook/react';
2
+ import { default as SchemaTab } from '../components/schema/SchemaTab';
3
+ declare const meta: {
4
+ title: string;
5
+ component: typeof SchemaTab;
6
+ decorators: ((Story: import('react').ComponentType) => import("react").JSX.Element)[];
7
+ };
8
+ export default meta;
9
+ type Story = StoryObj<typeof meta>;
10
+ export declare const Default: Story;
11
+ export declare const ConversionError: Story;
@@ -0,0 +1,16 @@
1
+ import { StoryObj } from '@storybook/react';
2
+ import { default as SearchPanel } from '../components/SearchPanel';
3
+ declare const meta: {
4
+ title: string;
5
+ component: typeof SearchPanel;
6
+ decorators: ((Story: import('react').ComponentType) => import("react").JSX.Element)[];
7
+ args: {
8
+ query: string;
9
+ onQueryChange: () => void;
10
+ results: never[];
11
+ onSelectResult: import('@vitest/spy').Mock<(...args: any[]) => any>;
12
+ };
13
+ };
14
+ export default meta;
15
+ type Story = StoryObj<typeof meta>;
16
+ export declare const Default: Story;
@@ -1,9 +1,11 @@
1
1
  import { StoryObj } from '@storybook/react';
2
- import { default as Servers } from '../containers/Server/Servers';
2
+ import { Servers } from '../public/sections';
3
3
  declare const meta: {
4
4
  title: string;
5
5
  component: typeof Servers;
6
+ decorators: ((Story: import('react').ComponentType) => import("react").JSX.Element)[];
6
7
  };
7
8
  export default meta;
8
9
  type Story = StoryObj<typeof meta>;
9
10
  export declare const Default: Story;
11
+ export declare const SingleServer: Story;
@@ -0,0 +1,10 @@
1
+ import { StoryObj } from '@storybook/react';
2
+ import { default as TabToggle } from '../components/TabToggle';
3
+ declare const meta: {
4
+ title: string;
5
+ component: typeof TabToggle;
6
+ decorators: ((Story: import('react').ComponentType) => import("react").JSX.Element)[];
7
+ };
8
+ export default meta;
9
+ type Story = StoryObj<typeof meta>;
10
+ export declare const Default: Story;
@@ -0,0 +1,11 @@
1
+ import { StoryObj } from '@storybook/react';
2
+ import { default as Tabs } from '../components/Tabs';
3
+ declare const meta: {
4
+ title: string;
5
+ component: typeof Tabs;
6
+ decorators: ((Story: import('react').ComponentType) => import("react").JSX.Element)[];
7
+ };
8
+ export default meta;
9
+ type Story = StoryObj<typeof meta>;
10
+ export declare const WithIcons: Story;
11
+ export declare const Plain: Story;
@@ -0,0 +1,25 @@
1
+ import { ComponentType } from 'react';
2
+ /**
3
+ * Centers a component story at one consistent max width and makes it fill that
4
+ * width. Scoped per-story (not global) on purpose: the full-page AsyncAPI
5
+ * example stories should render edge-to-edge, so centering must not be applied
6
+ * globally in preview.
7
+ */
8
+ export declare const centeredDecorator: (Story: ComponentType) => import("react").JSX.Element;
9
+ /**
10
+ * Shared Storybook decorator for rendering container components
11
+ * (Servers/Messages/Operations) in isolation. Those components — and their
12
+ * children (ChannelAddress, MessageDetails, the schema tree) — read from
13
+ * AsyncAPIDocumentContext via useAsyncAPIDocument, which throws without a
14
+ * provider. This wraps a story in that provider, backed by a real document.
15
+ *
16
+ * `resolveDocument` inlines the doc's $refs (server security, message
17
+ * payloads, …) the way the production render path does, so stories show
18
+ * fully-resolved content instead of raw { $ref } wrappers, and the `deref`
19
+ * fallback below resolves any refs left in place (e.g. cycle-forming ones).
20
+ */
21
+ export declare function buildDocumentContext(rawDoc: unknown): {
22
+ document: Record<string, unknown>;
23
+ deref: (refPath: string) => unknown;
24
+ decorator: (Story: ComponentType) => import("react").JSX.Element;
25
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apiuikit",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "A React UI library for rendering your API specifications",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -41,6 +41,7 @@
41
41
  "dependencies": {
42
42
  "@asyncapi/specs": "^6.8.1",
43
43
  "@json-schema-tools/reference-resolver": "^1.2.6",
44
+ "fuse.js": "^7.5.0",
44
45
  "highlight.js": "^11.11.1",
45
46
  "isomorphic-dompurify": "^2.24.0",
46
47
  "json-schema-faker": "^0.6.2",
@@ -49,7 +50,6 @@
49
50
  "marked-highlight": "^2.2.1",
50
51
  "protobufjs": "^7.4.0",
51
52
  "react-markdown": "^9.0.3",
52
- "react-syntax-highlighter": "^15.6.1",
53
53
  "remark-gfm": "^4.0.1"
54
54
  },
55
55
  "peerDependencies": {
@@ -81,7 +81,6 @@
81
81
  "@testing-library/react": "^16.3.2",
82
82
  "@types/react": "^19.0.0",
83
83
  "@types/react-dom": "^19.0.0",
84
- "@types/react-syntax-highlighter": "^15.5.13",
85
84
  "@vitejs/plugin-react": "^4.3.4",
86
85
  "eslint": "^9.17.0",
87
86
  "eslint-plugin-react-hooks": "^5.0.0",