@mdocui/react 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +265 -0
- package/dist/index.cjs +5093 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +81 -0
- package/dist/index.d.ts +81 -0
- package/dist/index.js +5033 -0
- package/dist/index.js.map +1 -0
- package/package.json +50 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as _mdocui_core from '@mdocui/core';
|
|
3
|
+
import { ActionEvent, ASTNode, ComponentRegistry, ParseMeta } from '@mdocui/core';
|
|
4
|
+
import * as react from 'react';
|
|
5
|
+
|
|
6
|
+
type ActionHandler = (event: ActionEvent) => void;
|
|
7
|
+
type ComponentMap = Record<string, React.ComponentType<ComponentProps>>;
|
|
8
|
+
interface ComponentProps {
|
|
9
|
+
name: string;
|
|
10
|
+
props: Record<string, unknown>;
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
onAction: ActionHandler;
|
|
13
|
+
isStreaming: boolean;
|
|
14
|
+
}
|
|
15
|
+
interface RendererContext {
|
|
16
|
+
components: ComponentMap;
|
|
17
|
+
onAction: ActionHandler;
|
|
18
|
+
isStreaming: boolean;
|
|
19
|
+
}
|
|
20
|
+
declare const MdocUIProvider: react.Provider<RendererContext | null>;
|
|
21
|
+
declare function useMdocUI(): RendererContext;
|
|
22
|
+
|
|
23
|
+
interface RendererProps {
|
|
24
|
+
nodes: ASTNode[];
|
|
25
|
+
components: ComponentMap;
|
|
26
|
+
onAction?: ActionHandler;
|
|
27
|
+
isStreaming?: boolean;
|
|
28
|
+
renderProse?: (content: string, key: string) => React.ReactNode;
|
|
29
|
+
}
|
|
30
|
+
declare function Renderer({ nodes, components, onAction, isStreaming, renderProse, }: RendererProps): react_jsx_runtime.JSX.Element;
|
|
31
|
+
|
|
32
|
+
interface UseRendererOptions {
|
|
33
|
+
registry: ComponentRegistry;
|
|
34
|
+
}
|
|
35
|
+
interface UseRendererReturn {
|
|
36
|
+
nodes: ASTNode[];
|
|
37
|
+
meta: ParseMeta;
|
|
38
|
+
isStreaming: boolean;
|
|
39
|
+
push: (chunk: string) => void;
|
|
40
|
+
done: () => void;
|
|
41
|
+
reset: () => void;
|
|
42
|
+
}
|
|
43
|
+
declare function useRenderer({ registry }: UseRendererOptions): UseRendererReturn;
|
|
44
|
+
|
|
45
|
+
declare const stack: _mdocui_core.ComponentDefinition;
|
|
46
|
+
declare const grid: _mdocui_core.ComponentDefinition;
|
|
47
|
+
declare const card: _mdocui_core.ComponentDefinition;
|
|
48
|
+
declare const divider: _mdocui_core.ComponentDefinition;
|
|
49
|
+
declare const accordion: _mdocui_core.ComponentDefinition;
|
|
50
|
+
declare const tabs: _mdocui_core.ComponentDefinition;
|
|
51
|
+
declare const tab: _mdocui_core.ComponentDefinition;
|
|
52
|
+
declare const button: _mdocui_core.ComponentDefinition;
|
|
53
|
+
declare const buttonGroup: _mdocui_core.ComponentDefinition;
|
|
54
|
+
declare const input: _mdocui_core.ComponentDefinition;
|
|
55
|
+
declare const select: _mdocui_core.ComponentDefinition;
|
|
56
|
+
declare const checkbox: _mdocui_core.ComponentDefinition;
|
|
57
|
+
declare const form: _mdocui_core.ComponentDefinition;
|
|
58
|
+
declare const chart: _mdocui_core.ComponentDefinition;
|
|
59
|
+
declare const table: _mdocui_core.ComponentDefinition;
|
|
60
|
+
declare const stat: _mdocui_core.ComponentDefinition;
|
|
61
|
+
declare const progress: _mdocui_core.ComponentDefinition;
|
|
62
|
+
declare const callout: _mdocui_core.ComponentDefinition;
|
|
63
|
+
declare const badge: _mdocui_core.ComponentDefinition;
|
|
64
|
+
declare const image: _mdocui_core.ComponentDefinition;
|
|
65
|
+
declare const codeBlock: _mdocui_core.ComponentDefinition;
|
|
66
|
+
declare const link: _mdocui_core.ComponentDefinition;
|
|
67
|
+
declare const allDefinitions: _mdocui_core.ComponentDefinition[];
|
|
68
|
+
declare const defaultGroups: ({
|
|
69
|
+
name: string;
|
|
70
|
+
components: string[];
|
|
71
|
+
notes: string[];
|
|
72
|
+
} | {
|
|
73
|
+
name: string;
|
|
74
|
+
components: string[];
|
|
75
|
+
notes?: undefined;
|
|
76
|
+
})[];
|
|
77
|
+
|
|
78
|
+
declare const defaultComponents: ComponentMap;
|
|
79
|
+
declare function createDefaultRegistry(): ComponentRegistry;
|
|
80
|
+
|
|
81
|
+
export { type ActionHandler, type ComponentMap, type ComponentProps, MdocUIProvider, Renderer, type RendererContext, type RendererProps, type UseRendererOptions, type UseRendererReturn, accordion, allDefinitions, badge, button, buttonGroup, callout, card, chart, checkbox, codeBlock, createDefaultRegistry, defaultComponents, defaultGroups, divider, form, grid, image, input, link, progress, select, stack, stat, tab, table, tabs, useMdocUI, useRenderer };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as _mdocui_core from '@mdocui/core';
|
|
3
|
+
import { ActionEvent, ASTNode, ComponentRegistry, ParseMeta } from '@mdocui/core';
|
|
4
|
+
import * as react from 'react';
|
|
5
|
+
|
|
6
|
+
type ActionHandler = (event: ActionEvent) => void;
|
|
7
|
+
type ComponentMap = Record<string, React.ComponentType<ComponentProps>>;
|
|
8
|
+
interface ComponentProps {
|
|
9
|
+
name: string;
|
|
10
|
+
props: Record<string, unknown>;
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
onAction: ActionHandler;
|
|
13
|
+
isStreaming: boolean;
|
|
14
|
+
}
|
|
15
|
+
interface RendererContext {
|
|
16
|
+
components: ComponentMap;
|
|
17
|
+
onAction: ActionHandler;
|
|
18
|
+
isStreaming: boolean;
|
|
19
|
+
}
|
|
20
|
+
declare const MdocUIProvider: react.Provider<RendererContext | null>;
|
|
21
|
+
declare function useMdocUI(): RendererContext;
|
|
22
|
+
|
|
23
|
+
interface RendererProps {
|
|
24
|
+
nodes: ASTNode[];
|
|
25
|
+
components: ComponentMap;
|
|
26
|
+
onAction?: ActionHandler;
|
|
27
|
+
isStreaming?: boolean;
|
|
28
|
+
renderProse?: (content: string, key: string) => React.ReactNode;
|
|
29
|
+
}
|
|
30
|
+
declare function Renderer({ nodes, components, onAction, isStreaming, renderProse, }: RendererProps): react_jsx_runtime.JSX.Element;
|
|
31
|
+
|
|
32
|
+
interface UseRendererOptions {
|
|
33
|
+
registry: ComponentRegistry;
|
|
34
|
+
}
|
|
35
|
+
interface UseRendererReturn {
|
|
36
|
+
nodes: ASTNode[];
|
|
37
|
+
meta: ParseMeta;
|
|
38
|
+
isStreaming: boolean;
|
|
39
|
+
push: (chunk: string) => void;
|
|
40
|
+
done: () => void;
|
|
41
|
+
reset: () => void;
|
|
42
|
+
}
|
|
43
|
+
declare function useRenderer({ registry }: UseRendererOptions): UseRendererReturn;
|
|
44
|
+
|
|
45
|
+
declare const stack: _mdocui_core.ComponentDefinition;
|
|
46
|
+
declare const grid: _mdocui_core.ComponentDefinition;
|
|
47
|
+
declare const card: _mdocui_core.ComponentDefinition;
|
|
48
|
+
declare const divider: _mdocui_core.ComponentDefinition;
|
|
49
|
+
declare const accordion: _mdocui_core.ComponentDefinition;
|
|
50
|
+
declare const tabs: _mdocui_core.ComponentDefinition;
|
|
51
|
+
declare const tab: _mdocui_core.ComponentDefinition;
|
|
52
|
+
declare const button: _mdocui_core.ComponentDefinition;
|
|
53
|
+
declare const buttonGroup: _mdocui_core.ComponentDefinition;
|
|
54
|
+
declare const input: _mdocui_core.ComponentDefinition;
|
|
55
|
+
declare const select: _mdocui_core.ComponentDefinition;
|
|
56
|
+
declare const checkbox: _mdocui_core.ComponentDefinition;
|
|
57
|
+
declare const form: _mdocui_core.ComponentDefinition;
|
|
58
|
+
declare const chart: _mdocui_core.ComponentDefinition;
|
|
59
|
+
declare const table: _mdocui_core.ComponentDefinition;
|
|
60
|
+
declare const stat: _mdocui_core.ComponentDefinition;
|
|
61
|
+
declare const progress: _mdocui_core.ComponentDefinition;
|
|
62
|
+
declare const callout: _mdocui_core.ComponentDefinition;
|
|
63
|
+
declare const badge: _mdocui_core.ComponentDefinition;
|
|
64
|
+
declare const image: _mdocui_core.ComponentDefinition;
|
|
65
|
+
declare const codeBlock: _mdocui_core.ComponentDefinition;
|
|
66
|
+
declare const link: _mdocui_core.ComponentDefinition;
|
|
67
|
+
declare const allDefinitions: _mdocui_core.ComponentDefinition[];
|
|
68
|
+
declare const defaultGroups: ({
|
|
69
|
+
name: string;
|
|
70
|
+
components: string[];
|
|
71
|
+
notes: string[];
|
|
72
|
+
} | {
|
|
73
|
+
name: string;
|
|
74
|
+
components: string[];
|
|
75
|
+
notes?: undefined;
|
|
76
|
+
})[];
|
|
77
|
+
|
|
78
|
+
declare const defaultComponents: ComponentMap;
|
|
79
|
+
declare function createDefaultRegistry(): ComponentRegistry;
|
|
80
|
+
|
|
81
|
+
export { type ActionHandler, type ComponentMap, type ComponentProps, MdocUIProvider, Renderer, type RendererContext, type RendererProps, type UseRendererOptions, type UseRendererReturn, accordion, allDefinitions, badge, button, buttonGroup, callout, card, chart, checkbox, codeBlock, createDefaultRegistry, defaultComponents, defaultGroups, divider, form, grid, image, input, link, progress, select, stack, stat, tab, table, tabs, useMdocUI, useRenderer };
|