@a2ui-sdk/react 0.1.1 → 0.2.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/dist/0.8/components/ComponentRenderer.d.ts +1 -19
- package/dist/0.8/components/ComponentRenderer.js +21 -63
- package/dist/0.8/components/UnknownComponent.d.ts +3 -3
- package/dist/0.8/components/display/AudioPlayerComponent.d.ts +3 -2
- package/dist/0.8/components/display/DividerComponent.d.ts +3 -2
- package/dist/0.8/components/display/IconComponent.d.ts +3 -2
- package/dist/0.8/components/display/ImageComponent.d.ts +3 -2
- package/dist/0.8/components/display/TextComponent.d.ts +3 -2
- package/dist/0.8/components/display/VideoComponent.d.ts +3 -2
- package/dist/0.8/components/index.d.ts +1 -1
- package/dist/0.8/components/interactive/ButtonComponent.d.ts +3 -2
- package/dist/0.8/components/interactive/CheckBoxComponent.d.ts +3 -2
- package/dist/0.8/components/interactive/DateTimeInputComponent.d.ts +3 -2
- package/dist/0.8/components/interactive/MultipleChoiceComponent.d.ts +3 -2
- package/dist/0.8/components/interactive/SliderComponent.d.ts +3 -2
- package/dist/0.8/components/interactive/TextFieldComponent.d.ts +3 -2
- package/dist/0.8/components/layout/CardComponent.d.ts +3 -2
- package/dist/0.8/components/layout/ColumnComponent.d.ts +3 -2
- package/dist/0.8/components/layout/ListComponent.d.ts +3 -2
- package/dist/0.8/components/layout/ModalComponent.d.ts +3 -2
- package/dist/0.8/components/layout/RowComponent.d.ts +3 -2
- package/dist/0.8/components/layout/TabsComponent.d.ts +3 -2
- package/dist/0.8/components/types.d.ts +8 -0
- package/dist/0.8/contexts/A2UIProvider.d.ts +37 -23
- package/dist/0.8/contexts/A2UIProvider.js +16 -22
- package/dist/0.8/contexts/ActionContext.js +5 -5
- package/dist/0.8/contexts/ComponentsMapContext.d.ts +8 -21
- package/dist/0.8/contexts/ComponentsMapContext.js +12 -16
- package/dist/0.8/contexts/DataModelContext.js +3 -3
- package/dist/0.8/index.d.ts +3 -1
- package/dist/0.8/index.js +11 -9
- package/dist/0.8/standard-catalog/index.d.ts +57 -0
- package/dist/0.8/standard-catalog/index.js +66 -0
- package/dist/0.9/A2UIRenderer.d.ts +9 -29
- package/dist/0.9/A2UIRenderer.js +27 -26
- package/dist/0.9/components/ComponentRenderer.d.ts +5 -19
- package/dist/0.9/components/ComponentRenderer.js +30 -17
- package/dist/0.9/components/UnknownComponent.d.ts +8 -2
- package/dist/0.9/components/UnknownComponent.js +13 -11
- package/dist/0.9/components/display/AudioPlayerComponent.d.ts +3 -2
- package/dist/0.9/components/display/AudioPlayerComponent.js +16 -14
- package/dist/0.9/components/display/DividerComponent.d.ts +3 -2
- package/dist/0.9/components/display/DividerComponent.js +4 -5
- package/dist/0.9/components/display/IconComponent.d.ts +3 -2
- package/dist/0.9/components/display/IconComponent.js +12 -12
- package/dist/0.9/components/display/ImageComponent.d.ts +3 -2
- package/dist/0.9/components/display/ImageComponent.js +18 -15
- package/dist/0.9/components/display/TextComponent.d.ts +3 -2
- package/dist/0.9/components/display/TextComponent.js +10 -8
- package/dist/0.9/components/display/VideoComponent.d.ts +3 -2
- package/dist/0.9/components/display/VideoComponent.js +7 -6
- package/dist/0.9/components/index.d.ts +4 -8
- package/dist/0.9/components/interactive/ButtonComponent.d.ts +3 -2
- package/dist/0.9/components/interactive/ButtonComponent.js +25 -20
- package/dist/0.9/components/interactive/CheckBoxComponent.d.ts +3 -2
- package/dist/0.9/components/interactive/CheckBoxComponent.js +33 -29
- package/dist/0.9/components/interactive/ChoicePickerComponent.d.ts +3 -2
- package/dist/0.9/components/interactive/ChoicePickerComponent.js +59 -53
- package/dist/0.9/components/interactive/DateTimeInputComponent.d.ts +3 -2
- package/dist/0.9/components/interactive/DateTimeInputComponent.js +32 -26
- package/dist/0.9/components/interactive/SliderComponent.d.ts +3 -2
- package/dist/0.9/components/interactive/SliderComponent.js +38 -32
- package/dist/0.9/components/interactive/TextFieldComponent.d.ts +3 -2
- package/dist/0.9/components/interactive/TextFieldComponent.js +41 -40
- package/dist/0.9/components/layout/CardComponent.d.ts +3 -2
- package/dist/0.9/components/layout/CardComponent.js +11 -10
- package/dist/0.9/components/layout/ColumnComponent.d.ts +3 -2
- package/dist/0.9/components/layout/ColumnComponent.js +26 -23
- package/dist/0.9/components/layout/ListComponent.d.ts +3 -2
- package/dist/0.9/components/layout/ListComponent.js +30 -27
- package/dist/0.9/components/layout/ModalComponent.d.ts +3 -2
- package/dist/0.9/components/layout/ModalComponent.js +11 -22
- package/dist/0.9/components/layout/RowComponent.d.ts +3 -2
- package/dist/0.9/components/layout/RowComponent.js +31 -28
- package/dist/0.9/components/layout/TabsComponent.d.ts +3 -2
- package/dist/0.9/components/layout/TabsComponent.js +21 -21
- package/dist/0.9/components/types.d.ts +8 -0
- package/dist/0.9/contexts/A2UIProvider.d.ts +45 -28
- package/dist/0.9/contexts/A2UIProvider.js +18 -26
- package/dist/0.9/contexts/ActionContext.js +5 -5
- package/dist/0.9/contexts/ComponentsMapContext.d.ts +8 -31
- package/dist/0.9/contexts/ComponentsMapContext.js +12 -16
- package/dist/0.9/contexts/ScopeContext.js +3 -3
- package/dist/0.9/contexts/SurfaceContext.d.ts +3 -3
- package/dist/0.9/contexts/SurfaceContext.js +3 -3
- package/dist/0.9/hooks/useComponent.d.ts +2 -2
- package/dist/0.9/hooks/useDataBinding.js +3 -3
- package/dist/0.9/index.d.ts +6 -4
- package/dist/0.9/index.js +12 -10
- package/dist/0.9/standard-catalog/index.d.ts +61 -0
- package/dist/0.9/standard-catalog/index.js +69 -0
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/lib/utils.d.ts +5 -0
- package/dist/lib/utils.js +6 -4
- package/package.json +13 -4
- package/dist/0.9/components/index.js +0 -68
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as C } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useContext as P, createContext as f, useState as V, useCallback as a, useMemo as v } from "react";
|
|
3
3
|
import { mergeAtPath as b, getValueByPath as y, setValueByPath as B } from "@a2ui-sdk/utils/0.8";
|
|
4
|
-
const g =
|
|
4
|
+
const g = f(
|
|
5
5
|
null
|
|
6
6
|
);
|
|
7
7
|
function E({ children: u }) {
|
|
@@ -72,7 +72,7 @@ function E({ children: u }) {
|
|
|
72
72
|
return /* @__PURE__ */ C(g.Provider, { value: h, children: u });
|
|
73
73
|
}
|
|
74
74
|
function S() {
|
|
75
|
-
const u =
|
|
75
|
+
const u = P(g);
|
|
76
76
|
if (!u)
|
|
77
77
|
throw new Error(
|
|
78
78
|
"useDataModelContext must be used within a DataModelProvider"
|
package/dist/0.8/index.d.ts
CHANGED
|
@@ -33,11 +33,13 @@
|
|
|
33
33
|
* ```
|
|
34
34
|
*/
|
|
35
35
|
export type { A2UIMessage, ActionPayload as A2UIAction, Action, ValueSource, } from '@a2ui-sdk/types/0.8';
|
|
36
|
-
export type { A2UIProviderProps
|
|
36
|
+
export type { A2UIProviderProps } from './contexts/A2UIProvider';
|
|
37
37
|
export type { A2UIRendererProps } from './A2UIRenderer';
|
|
38
|
+
export type { Catalog, CatalogComponent, CatalogComponents, CatalogFunctions, } from './standard-catalog';
|
|
38
39
|
export { A2UIProvider } from './contexts/A2UIProvider';
|
|
39
40
|
export { A2UIRenderer } from './A2UIRenderer';
|
|
40
41
|
export { ComponentRenderer } from './components/ComponentRenderer';
|
|
42
|
+
export { standardCatalog } from './standard-catalog';
|
|
41
43
|
export { useDispatchAction } from './hooks/useDispatchAction';
|
|
42
44
|
export { useDataBinding, useFormBinding } from './hooks/useDataBinding';
|
|
43
45
|
export { useSurfaceContext } from './contexts/SurfaceContext';
|
package/dist/0.8/index.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { A2UIProvider as r } from "./contexts/A2UIProvider.js";
|
|
2
2
|
import { A2UIRenderer as n } from "./A2UIRenderer.js";
|
|
3
|
-
import { ComponentRenderer as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { ComponentRenderer as m } from "./components/ComponentRenderer.js";
|
|
4
|
+
import { standardCatalog as x } from "./standard-catalog/index.js";
|
|
5
|
+
import { useDispatchAction as d } from "./hooks/useDispatchAction.js";
|
|
6
|
+
import { useDataBinding as s, useFormBinding as u } from "./hooks/useDataBinding.js";
|
|
7
|
+
import { useSurfaceContext as c } from "./contexts/SurfaceContext.js";
|
|
7
8
|
import { useDataModelContext as A } from "./contexts/DataModelContext.js";
|
|
8
9
|
export {
|
|
9
10
|
r as A2UIProvider,
|
|
10
11
|
n as A2UIRenderer,
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
m as ComponentRenderer,
|
|
13
|
+
x as standardCatalog,
|
|
14
|
+
s as useDataBinding,
|
|
13
15
|
A as useDataModelContext,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
d as useDispatchAction,
|
|
17
|
+
u as useFormBinding,
|
|
18
|
+
c as useSurfaceContext
|
|
17
19
|
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
import { TextComponent, ImageComponent, IconComponent, VideoComponent, AudioPlayerComponent, DividerComponent } from '../components/display';
|
|
3
|
+
import { RowComponent, ColumnComponent, ListComponent, CardComponent, TabsComponent, ModalComponent } from '../components/layout';
|
|
4
|
+
import { ButtonComponent, CheckBoxComponent, TextFieldComponent, DateTimeInputComponent, MultipleChoiceComponent, SliderComponent } from '../components/interactive';
|
|
5
|
+
import { A2UIComponentProps } from '../components/types';
|
|
6
|
+
/**
|
|
7
|
+
* Type for a component in the catalog.
|
|
8
|
+
*/
|
|
9
|
+
export type CatalogComponent = ComponentType<A2UIComponentProps>;
|
|
10
|
+
/**
|
|
11
|
+
* Type for the components registry in a catalog.
|
|
12
|
+
*/
|
|
13
|
+
export type CatalogComponents = Record<string, CatalogComponent>;
|
|
14
|
+
/**
|
|
15
|
+
* Type for functions in a catalog (reserved for future use).
|
|
16
|
+
*/
|
|
17
|
+
export type CatalogFunctions = Record<string, unknown>;
|
|
18
|
+
/**
|
|
19
|
+
* Type for a catalog containing components and functions.
|
|
20
|
+
*/
|
|
21
|
+
export interface Catalog {
|
|
22
|
+
/** Component registry mapping type names to React components */
|
|
23
|
+
components: CatalogComponents;
|
|
24
|
+
/** Function registry (reserved for future use) */
|
|
25
|
+
functions?: CatalogFunctions;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Standard components included in the default catalog.
|
|
29
|
+
*/
|
|
30
|
+
export declare const standardComponents: CatalogComponents;
|
|
31
|
+
/**
|
|
32
|
+
* Standard functions included in the default catalog (reserved for future use).
|
|
33
|
+
*/
|
|
34
|
+
/**
|
|
35
|
+
* The standard catalog containing all built-in A2UI v0.8 components and functions.
|
|
36
|
+
*
|
|
37
|
+
* This is the default catalog used when no custom catalog is provided to A2UIProvider.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* // Use as-is
|
|
42
|
+
* <A2UIProvider messages={messages} catalog={standardCatalog}>
|
|
43
|
+
* <A2UIRenderer />
|
|
44
|
+
* </A2UIProvider>
|
|
45
|
+
*
|
|
46
|
+
* // Extend with custom components
|
|
47
|
+
* const myCatalog = {
|
|
48
|
+
* ...standardCatalog,
|
|
49
|
+
* components: {
|
|
50
|
+
* ...standardCatalog.components,
|
|
51
|
+
* MyComponent: MyComponentImpl,
|
|
52
|
+
* },
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare const standardCatalog: Catalog;
|
|
57
|
+
export { TextComponent, ImageComponent, IconComponent, VideoComponent, AudioPlayerComponent, DividerComponent, RowComponent, ColumnComponent, ListComponent, CardComponent, TabsComponent, ModalComponent, ButtonComponent, CheckBoxComponent, TextFieldComponent, DateTimeInputComponent, MultipleChoiceComponent, SliderComponent, };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { SliderComponent as o } from "../components/interactive/SliderComponent.js";
|
|
2
|
+
import { MultipleChoiceComponent as m } from "../components/interactive/MultipleChoiceComponent.js";
|
|
3
|
+
import { DateTimeInputComponent as t } from "../components/interactive/DateTimeInputComponent.js";
|
|
4
|
+
import { TextFieldComponent as n } from "../components/interactive/TextFieldComponent.js";
|
|
5
|
+
import { CheckBoxComponent as e } from "../components/interactive/CheckBoxComponent.js";
|
|
6
|
+
import { ButtonComponent as r } from "../components/interactive/ButtonComponent.js";
|
|
7
|
+
import { ModalComponent as p } from "../components/layout/ModalComponent.js";
|
|
8
|
+
import { TabsComponent as i } from "../components/layout/TabsComponent.js";
|
|
9
|
+
import { CardComponent as C } from "../components/layout/CardComponent.js";
|
|
10
|
+
import { ListComponent as a } from "../components/layout/ListComponent.js";
|
|
11
|
+
import { ColumnComponent as d } from "../components/layout/ColumnComponent.js";
|
|
12
|
+
import { RowComponent as f } from "../components/layout/RowComponent.js";
|
|
13
|
+
import { DividerComponent as l } from "../components/display/DividerComponent.js";
|
|
14
|
+
import { AudioPlayerComponent as s } from "../components/display/AudioPlayerComponent.js";
|
|
15
|
+
import { VideoComponent as u } from "../components/display/VideoComponent.js";
|
|
16
|
+
import { IconComponent as c } from "../components/display/IconComponent.js";
|
|
17
|
+
import { ImageComponent as T } from "../components/display/ImageComponent.js";
|
|
18
|
+
import { TextComponent as x } from "../components/display/TextComponent.js";
|
|
19
|
+
const I = {
|
|
20
|
+
// Display components
|
|
21
|
+
Text: x,
|
|
22
|
+
Image: T,
|
|
23
|
+
Icon: c,
|
|
24
|
+
Video: u,
|
|
25
|
+
AudioPlayer: s,
|
|
26
|
+
Divider: l,
|
|
27
|
+
// Layout components
|
|
28
|
+
Row: f,
|
|
29
|
+
Column: d,
|
|
30
|
+
List: a,
|
|
31
|
+
Card: C,
|
|
32
|
+
Tabs: i,
|
|
33
|
+
Modal: p,
|
|
34
|
+
// Interactive components
|
|
35
|
+
Button: r,
|
|
36
|
+
CheckBox: e,
|
|
37
|
+
TextField: n,
|
|
38
|
+
DateTimeInput: t,
|
|
39
|
+
MultipleChoice: m,
|
|
40
|
+
Slider: o
|
|
41
|
+
}, q = {
|
|
42
|
+
components: I
|
|
43
|
+
// functions: standardFunctions,
|
|
44
|
+
};
|
|
45
|
+
export {
|
|
46
|
+
s as AudioPlayerComponent,
|
|
47
|
+
r as ButtonComponent,
|
|
48
|
+
C as CardComponent,
|
|
49
|
+
e as CheckBoxComponent,
|
|
50
|
+
d as ColumnComponent,
|
|
51
|
+
t as DateTimeInputComponent,
|
|
52
|
+
l as DividerComponent,
|
|
53
|
+
c as IconComponent,
|
|
54
|
+
T as ImageComponent,
|
|
55
|
+
a as ListComponent,
|
|
56
|
+
p as ModalComponent,
|
|
57
|
+
m as MultipleChoiceComponent,
|
|
58
|
+
f as RowComponent,
|
|
59
|
+
o as SliderComponent,
|
|
60
|
+
i as TabsComponent,
|
|
61
|
+
x as TextComponent,
|
|
62
|
+
n as TextFieldComponent,
|
|
63
|
+
u as VideoComponent,
|
|
64
|
+
q as standardCatalog,
|
|
65
|
+
I as standardComponents
|
|
66
|
+
};
|
|
@@ -1,32 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
* A2UIRenderer - Component for rendering A2UI 0.9 surfaces.
|
|
3
|
-
*
|
|
4
|
-
* This component renders the surfaces from the A2UI context.
|
|
5
|
-
* It must be used within an A2UIProvider.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```tsx
|
|
9
|
-
* import { A2UIProvider, A2UIRenderer, A2UIMessage, A2UIAction } from '@a2ui-sdk/react/0.9'
|
|
10
|
-
*
|
|
11
|
-
* function App() {
|
|
12
|
-
* const messages: A2UIMessage[] = [...]
|
|
13
|
-
* const handleAction = (action: A2UIAction) => {
|
|
14
|
-
* console.log('Action:', action)
|
|
15
|
-
* }
|
|
16
|
-
* return (
|
|
17
|
-
* <A2UIProvider messages={messages} onAction={handleAction}>
|
|
18
|
-
* <A2UIRenderer />
|
|
19
|
-
* </A2UIProvider>
|
|
20
|
-
* )
|
|
21
|
-
* }
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
1
|
+
import { ActionHandler } from '@a2ui-sdk/types/0.9';
|
|
24
2
|
/**
|
|
25
3
|
* Props for A2UIRenderer.
|
|
26
4
|
*/
|
|
27
5
|
export interface A2UIRendererProps {
|
|
28
6
|
/** Optional surface ID to render a specific surface (renders all if not provided) */
|
|
29
7
|
surfaceId?: string;
|
|
8
|
+
/** Callback when an action is dispatched */
|
|
9
|
+
onAction?: ActionHandler;
|
|
30
10
|
}
|
|
31
11
|
/**
|
|
32
12
|
* Component for rendering A2UI 0.9 surfaces.
|
|
@@ -37,18 +17,18 @@ export interface A2UIRendererProps {
|
|
|
37
17
|
* @example
|
|
38
18
|
* ```tsx
|
|
39
19
|
* // Render all surfaces
|
|
40
|
-
* <A2UIProvider messages={messages}
|
|
41
|
-
* <A2UIRenderer />
|
|
20
|
+
* <A2UIProvider messages={messages}>
|
|
21
|
+
* <A2UIRenderer onAction={handleAction} />
|
|
42
22
|
* </A2UIProvider>
|
|
43
23
|
*
|
|
44
24
|
* // Render specific surface
|
|
45
|
-
* <A2UIProvider messages={messages}
|
|
46
|
-
* <A2UIRenderer surfaceId="sidebar" />
|
|
47
|
-
* <A2UIRenderer surfaceId="main" />
|
|
25
|
+
* <A2UIProvider messages={messages}>
|
|
26
|
+
* <A2UIRenderer surfaceId="sidebar" onAction={handleAction} />
|
|
27
|
+
* <A2UIRenderer surfaceId="main" onAction={handleAction} />
|
|
48
28
|
* </A2UIProvider>
|
|
49
29
|
* ```
|
|
50
30
|
*/
|
|
51
|
-
export declare function A2UIRenderer({ surfaceId }: A2UIRendererProps): import("react/jsx-runtime").JSX.Element | null;
|
|
31
|
+
export declare function A2UIRenderer({ surfaceId, onAction }: A2UIRendererProps): import("react/jsx-runtime").JSX.Element | null;
|
|
52
32
|
export declare namespace A2UIRenderer {
|
|
53
33
|
var displayName: string;
|
|
54
34
|
}
|
package/dist/0.9/A2UIRenderer.js
CHANGED
|
@@ -1,41 +1,42 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
2
2
|
import { useSurfaceContext as a } from "./contexts/SurfaceContext.js";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { ActionProvider as c } from "./contexts/ActionContext.js";
|
|
4
|
+
import { ComponentRenderer as s } from "./components/ComponentRenderer.js";
|
|
5
|
+
function l(o) {
|
|
6
|
+
if (o.has("root"))
|
|
6
7
|
return "root";
|
|
7
|
-
const
|
|
8
|
-
for (const r of
|
|
8
|
+
const n = /* @__PURE__ */ new Set();
|
|
9
|
+
for (const r of o.values()) {
|
|
9
10
|
if ("children" in r) {
|
|
10
|
-
const
|
|
11
|
-
Array.isArray(
|
|
11
|
+
const t = r.children;
|
|
12
|
+
Array.isArray(t) && t.forEach((e) => n.add(e));
|
|
12
13
|
}
|
|
13
|
-
"child" in r && typeof r.child == "string" &&
|
|
14
|
-
|
|
14
|
+
"child" in r && typeof r.child == "string" && n.add(r.child), "trigger" in r && typeof r.trigger == "string" && n.add(r.trigger), "content" in r && typeof r.content == "string" && n.add(r.content), "tabs" in r && Array.isArray(r.tabs) && r.tabs.forEach((t) => {
|
|
15
|
+
t.child && n.add(t.child);
|
|
15
16
|
});
|
|
16
17
|
}
|
|
17
|
-
for (const [r] of
|
|
18
|
-
if (!
|
|
18
|
+
for (const [r] of o)
|
|
19
|
+
if (!n.has(r))
|
|
19
20
|
return r;
|
|
20
21
|
}
|
|
21
|
-
function
|
|
22
|
-
const { surfaces:
|
|
23
|
-
if (
|
|
24
|
-
const
|
|
25
|
-
if (!
|
|
22
|
+
function u({ surfaceId: o, onAction: n }) {
|
|
23
|
+
const { surfaces: r } = a();
|
|
24
|
+
if (o) {
|
|
25
|
+
const e = r.get(o);
|
|
26
|
+
if (!e || !e.created)
|
|
26
27
|
return null;
|
|
27
|
-
const
|
|
28
|
-
return
|
|
28
|
+
const i = l(e.components);
|
|
29
|
+
return i ? /* @__PURE__ */ d(c, { onAction: n, children: /* @__PURE__ */ d(s, { surfaceId: o, componentId: i }) }) : null;
|
|
29
30
|
}
|
|
30
|
-
const
|
|
31
|
-
return
|
|
32
|
-
if (!
|
|
31
|
+
const t = Array.from(r.entries());
|
|
32
|
+
return t.length === 0 ? null : /* @__PURE__ */ d(c, { onAction: n, children: t.map(([e, i]) => {
|
|
33
|
+
if (!i.created)
|
|
33
34
|
return null;
|
|
34
|
-
const
|
|
35
|
-
return
|
|
35
|
+
const f = l(i.components);
|
|
36
|
+
return f ? /* @__PURE__ */ d(s, { surfaceId: e, componentId: f }, e) : null;
|
|
36
37
|
}) });
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
+
u.displayName = "A2UI.Renderer";
|
|
39
40
|
export {
|
|
40
|
-
|
|
41
|
+
u as A2UIRenderer
|
|
41
42
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ComponentType } from 'react';
|
|
2
|
-
import { A2UIComponentProps } from '../contexts/ComponentsMapContext';
|
|
3
1
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* ComponentRenderer - Routes component rendering based on type.
|
|
3
|
+
*
|
|
4
|
+
* Uses the flat discriminator format from 0.9 protocol where
|
|
5
|
+
* the component type is a property on the component itself.
|
|
6
|
+
* Props are spread directly to components like in v0.8.
|
|
6
7
|
*/
|
|
7
|
-
export declare const componentRegistry: Record<string, ComponentType<A2UIComponentProps>>;
|
|
8
8
|
/**
|
|
9
9
|
* Props for ComponentRenderer.
|
|
10
10
|
*/
|
|
@@ -23,17 +23,3 @@ export interface ComponentRendererProps {
|
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
25
|
export declare const ComponentRenderer: import('react').NamedExoticComponent<ComponentRendererProps>;
|
|
26
|
-
/**
|
|
27
|
-
* Registers a component type in the default registry.
|
|
28
|
-
*
|
|
29
|
-
* @param type - The component type name
|
|
30
|
-
* @param component - The React component to register
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* ```tsx
|
|
34
|
-
* registerComponent('CustomChart', ({ surfaceId, component }) => {
|
|
35
|
-
* return <Chart data={component.data} />;
|
|
36
|
-
* });
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
export declare function registerComponent(type: string, component: ComponentType<A2UIComponentProps>): void;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { memo as
|
|
3
|
-
import { useComponent as
|
|
4
|
-
import { ComponentsMapContext as
|
|
5
|
-
import { UnknownComponent as
|
|
6
|
-
const
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { memo as c, useContext as l } from "react";
|
|
3
|
+
import { useComponent as f } from "../hooks/useComponent.js";
|
|
4
|
+
import { ComponentsMapContext as u } from "../contexts/ComponentsMapContext.js";
|
|
5
|
+
import { UnknownComponent as a } from "./UnknownComponent.js";
|
|
6
|
+
const r = /* @__PURE__ */ new Set(), y = c(function({
|
|
7
7
|
surfaceId: n,
|
|
8
8
|
componentId: o
|
|
9
9
|
}) {
|
|
10
|
-
const e =
|
|
11
|
-
if (
|
|
10
|
+
const e = f(n, o), s = l(u), t = `${n}:${o}`;
|
|
11
|
+
if (r.has(t))
|
|
12
12
|
return console.error(
|
|
13
13
|
`[A2UI 0.9] Circular reference detected for component "${o}" on surface "${n}". Skipping render.`
|
|
14
14
|
), null;
|
|
@@ -16,19 +16,32 @@ const a = {}, m = /* @__PURE__ */ new Set(), y = l(function({
|
|
|
16
16
|
return console.warn(
|
|
17
17
|
`[A2UI 0.9] Component not found: ${o} on surface ${n}`
|
|
18
18
|
), null;
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
const p = e.component, m = s?.getComponent(p);
|
|
20
|
+
if (!m)
|
|
21
|
+
return /* @__PURE__ */ i(
|
|
22
|
+
a,
|
|
23
|
+
{
|
|
24
|
+
surfaceId: n,
|
|
25
|
+
componentId: o,
|
|
26
|
+
componentType: p
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
r.add(t);
|
|
30
|
+
const { component: d, id: x, ...C } = e;
|
|
24
31
|
try {
|
|
25
|
-
return /* @__PURE__ */
|
|
32
|
+
return /* @__PURE__ */ i(
|
|
33
|
+
m,
|
|
34
|
+
{
|
|
35
|
+
surfaceId: n,
|
|
36
|
+
componentId: o,
|
|
37
|
+
...C
|
|
38
|
+
}
|
|
39
|
+
);
|
|
26
40
|
} finally {
|
|
27
|
-
|
|
41
|
+
r.delete(t);
|
|
28
42
|
}
|
|
29
43
|
});
|
|
30
44
|
y.displayName = "A2UI.ComponentRenderer";
|
|
31
45
|
export {
|
|
32
|
-
y as ComponentRenderer
|
|
33
|
-
a as componentRegistry
|
|
46
|
+
y as ComponentRenderer
|
|
34
47
|
};
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import { A2UIComponentProps } from '
|
|
1
|
+
import { A2UIComponentProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Props for UnknownComponent.
|
|
4
|
+
*/
|
|
5
|
+
export interface UnknownComponentProps {
|
|
6
|
+
componentType: string;
|
|
7
|
+
}
|
|
2
8
|
/**
|
|
3
9
|
* Fallback component for unknown types.
|
|
4
10
|
*
|
|
5
11
|
* Displays a warning box with the unknown component type name
|
|
6
12
|
* to help developers identify configuration issues.
|
|
7
13
|
*/
|
|
8
|
-
export declare function UnknownComponent({
|
|
14
|
+
export declare function UnknownComponent({ componentId, componentType, }: A2UIComponentProps<UnknownComponentProps>): import("react/jsx-runtime").JSX.Element;
|
|
9
15
|
export declare namespace UnknownComponent {
|
|
10
16
|
var displayName: string;
|
|
11
17
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
function
|
|
3
|
-
|
|
1
|
+
import { jsxs as e, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
function p({
|
|
3
|
+
componentId: n,
|
|
4
|
+
componentType: o
|
|
5
|
+
}) {
|
|
4
6
|
return process.env.NODE_ENV === "development" && console.warn(
|
|
5
|
-
`[A2UI 0.9] Unknown component type "${o}" (id: ${
|
|
6
|
-
), /* @__PURE__ */
|
|
7
|
+
`[A2UI 0.9] Unknown component type "${o}" (id: ${n}). Make sure the component type is correct or provide a custom component.`
|
|
8
|
+
), /* @__PURE__ */ e(
|
|
7
9
|
"div",
|
|
8
10
|
{
|
|
9
11
|
style: {
|
|
@@ -17,19 +19,19 @@ function r({ component: n }) {
|
|
|
17
19
|
fontFamily: "monospace"
|
|
18
20
|
},
|
|
19
21
|
children: [
|
|
20
|
-
/* @__PURE__ */
|
|
22
|
+
/* @__PURE__ */ r("strong", { children: "Unknown component:" }),
|
|
21
23
|
" ",
|
|
22
24
|
o,
|
|
23
|
-
/* @__PURE__ */
|
|
24
|
-
/* @__PURE__ */
|
|
25
|
+
/* @__PURE__ */ r("br", {}),
|
|
26
|
+
/* @__PURE__ */ e("span", { style: { opacity: 0.7 }, children: [
|
|
25
27
|
"ID: ",
|
|
26
|
-
|
|
28
|
+
n
|
|
27
29
|
] })
|
|
28
30
|
]
|
|
29
31
|
}
|
|
30
32
|
);
|
|
31
33
|
}
|
|
32
|
-
|
|
34
|
+
p.displayName = "A2UI.UnknownComponent";
|
|
33
35
|
export {
|
|
34
|
-
|
|
36
|
+
p as UnknownComponent
|
|
35
37
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AudioPlayerComponentProps } from '@a2ui-sdk/types/0.9/standard-catalog';
|
|
2
|
+
import { A2UIComponentProps } from '../types';
|
|
2
3
|
/**
|
|
3
4
|
* AudioPlayer component for playing audio content.
|
|
4
5
|
*/
|
|
5
|
-
export declare const AudioPlayerComponent: import('react').NamedExoticComponent<A2UIComponentProps
|
|
6
|
+
export declare const AudioPlayerComponent: import('react').NamedExoticComponent<A2UIComponentProps<AudioPlayerComponentProps>>;
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { memo as
|
|
3
|
-
import { useStringBinding as
|
|
4
|
-
import { cn as
|
|
5
|
-
const
|
|
6
|
-
surfaceId:
|
|
7
|
-
|
|
1
|
+
import { jsxs as d, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { memo as u } from "react";
|
|
3
|
+
import { useStringBinding as i } from "../../hooks/useDataBinding.js";
|
|
4
|
+
import { cn as c } from "../../../lib/utils.js";
|
|
5
|
+
const a = u(function({
|
|
6
|
+
surfaceId: o,
|
|
7
|
+
url: l,
|
|
8
|
+
description: s,
|
|
9
|
+
weight: e
|
|
8
10
|
}) {
|
|
9
|
-
const
|
|
11
|
+
const r = i(o, l, ""), t = i(o, s, "");
|
|
10
12
|
if (!r)
|
|
11
13
|
return null;
|
|
12
|
-
const
|
|
13
|
-
return /* @__PURE__ */
|
|
14
|
-
t && /* @__PURE__ */
|
|
15
|
-
/* @__PURE__ */
|
|
14
|
+
const m = e ? { flexGrow: e } : void 0;
|
|
15
|
+
return /* @__PURE__ */ d("div", { className: c("flex flex-col gap-2"), style: m, children: [
|
|
16
|
+
t && /* @__PURE__ */ n("p", { className: "text-sm text-muted-foreground", children: t }),
|
|
17
|
+
/* @__PURE__ */ n("audio", { src: r, controls: !0, className: "w-full", children: "Your browser does not support the audio element." })
|
|
16
18
|
] });
|
|
17
19
|
});
|
|
18
|
-
|
|
20
|
+
a.displayName = "A2UI.AudioPlayer";
|
|
19
21
|
export {
|
|
20
|
-
|
|
22
|
+
a as AudioPlayerComponent
|
|
21
23
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DividerComponentProps } from '@a2ui-sdk/types/0.9/standard-catalog';
|
|
2
|
+
import { A2UIComponentProps } from '../types';
|
|
2
3
|
/**
|
|
3
4
|
* Divider component for visual separation.
|
|
4
5
|
*/
|
|
5
|
-
export declare const DividerComponent: import('react').NamedExoticComponent<A2UIComponentProps
|
|
6
|
+
export declare const DividerComponent: import('react').NamedExoticComponent<A2UIComponentProps<DividerComponentProps>>;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
2
|
import { memo as t } from "react";
|
|
3
3
|
import { Separator as e } from "../../../components/ui/separator.js";
|
|
4
|
-
const
|
|
5
|
-
|
|
4
|
+
const i = t(function({
|
|
5
|
+
axis: o = "horizontal"
|
|
6
6
|
}) {
|
|
7
|
-
const o = i.axis ?? "horizontal";
|
|
8
7
|
return /* @__PURE__ */ r(
|
|
9
8
|
e,
|
|
10
9
|
{
|
|
@@ -13,7 +12,7 @@ const m = t(function({
|
|
|
13
12
|
}
|
|
14
13
|
);
|
|
15
14
|
});
|
|
16
|
-
|
|
15
|
+
i.displayName = "A2UI.Divider";
|
|
17
16
|
export {
|
|
18
|
-
|
|
17
|
+
i as DividerComponent
|
|
19
18
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IconComponentProps } from '@a2ui-sdk/types/0.9/standard-catalog';
|
|
2
|
+
import { A2UIComponentProps } from '../types';
|
|
2
3
|
/**
|
|
3
4
|
* Icon component for displaying icons from the A2UI icon set.
|
|
4
5
|
*/
|
|
5
|
-
export declare const IconComponent: import('react').NamedExoticComponent<A2UIComponentProps
|
|
6
|
+
export declare const IconComponent: import('react').NamedExoticComponent<A2UIComponentProps<IconComponentProps>>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { memo as
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { memo as i } from "react";
|
|
3
3
|
import { useStringBinding as l } from "../../hooks/useDataBinding.js";
|
|
4
4
|
import { AlertTriangle as c, EyeOff as f, Eye as s, Upload as m, StarOff as p, StarHalf as d, Star as h, ShoppingCart as C, Share2 as u, Settings as w, Send as g, Search as O, RefreshCw as S, Printer as k, Image as y, Phone as o, User as H, CreditCard as I, Bell as U, BellOff as A, MoreHorizontal as M, MoreVertical as P, Menu as v, Mail as B, Unlock as F, Lock as N, MapPin as T, Info as b, Home as x, HelpCircle as z, Folder as D, HeartOff as E, Heart as L, AlertCircle as R, CalendarDays as V, Pencil as j, Download as X, Trash2 as $, X as q, Check as G, Camera as J, Calendar as K, Paperclip as Q, ArrowRight as W, ArrowLeft as Y, Plus as Z, UserCircle as _ } from "lucide-react";
|
|
5
|
-
import { cn as
|
|
6
|
-
const
|
|
5
|
+
import { cn as rr } from "../../../lib/utils.js";
|
|
6
|
+
const er = {
|
|
7
7
|
accountCircle: _,
|
|
8
8
|
add: Z,
|
|
9
9
|
arrowBack: Y,
|
|
@@ -52,17 +52,17 @@ const re = {
|
|
|
52
52
|
visibility: s,
|
|
53
53
|
visibilityOff: f,
|
|
54
54
|
warning: c
|
|
55
|
-
},
|
|
55
|
+
}, or = i(function({
|
|
56
56
|
surfaceId: n,
|
|
57
|
-
|
|
57
|
+
name: a
|
|
58
58
|
}) {
|
|
59
|
-
const
|
|
60
|
-
if (!
|
|
59
|
+
const r = l(n, a, "");
|
|
60
|
+
if (!r)
|
|
61
61
|
return null;
|
|
62
|
-
const
|
|
63
|
-
return
|
|
62
|
+
const e = er[r];
|
|
63
|
+
return e ? /* @__PURE__ */ t(e, { className: rr("w-5 h-5") }) : (console.warn(`[A2UI 0.9] Unknown icon name: ${r}`), null);
|
|
64
64
|
});
|
|
65
|
-
|
|
65
|
+
or.displayName = "A2UI.Icon";
|
|
66
66
|
export {
|
|
67
|
-
|
|
67
|
+
or as IconComponent
|
|
68
68
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ImageComponentProps } from '@a2ui-sdk/types/0.9/standard-catalog';
|
|
2
|
+
import { A2UIComponentProps } from '../types';
|
|
2
3
|
/**
|
|
3
4
|
* Image component for displaying images.
|
|
4
5
|
* Supports different sizes via variant and object-fit via fit property.
|
|
5
6
|
*/
|
|
6
|
-
export declare const ImageComponent: import('react').NamedExoticComponent<A2UIComponentProps
|
|
7
|
+
export declare const ImageComponent: import('react').NamedExoticComponent<A2UIComponentProps<ImageComponentProps>>;
|