@zhama/a2ui-core 0.6.0 → 0.9.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.
- package/README.md +11 -11
- package/dist/builders/index.cjs +3 -3
- package/dist/builders/index.d.cts +96 -411
- package/dist/builders/index.d.ts +96 -411
- package/dist/builders/index.js +3 -3
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +3 -3
- package/dist/primitives-DRaAeo-1.d.cts +148 -0
- package/dist/primitives-DRaAeo-1.d.ts +148 -0
- package/dist/surface/index.cjs +2 -2
- package/dist/surface/index.d.cts +29 -16
- package/dist/surface/index.d.ts +29 -16
- package/dist/surface/index.js +2 -2
- package/dist/types/index.cjs +2 -2
- package/dist/types/index.d.cts +398 -318
- package/dist/types/index.d.ts +398 -318
- package/dist/types/index.js +2 -2
- package/dist/utils/index.cjs +1 -1
- package/dist/utils/index.d.cts +8 -16
- package/dist/utils/index.d.ts +8 -16
- package/dist/utils/index.js +1 -1
- package/dist/validators/index.cjs +1 -1
- package/dist/validators/index.d.cts +6 -39
- package/dist/validators/index.d.ts +6 -39
- package/dist/validators/index.js +1 -1
- package/package.json +1 -1
- package/dist/primitives-DLbBDhLq.d.cts +0 -46
- package/dist/primitives-DLbBDhLq.d.ts +0 -46
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
// Builders
|
|
31
31
|
text, column, button, h1,
|
|
32
32
|
createSurface, updateComponents, updateDataModel,
|
|
33
|
-
|
|
33
|
+
createMessages,
|
|
34
34
|
|
|
35
35
|
// Surface
|
|
36
36
|
SURFACE_IDS, createA2UISurface,
|
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
|
|
44
44
|
// Types
|
|
45
45
|
type ComponentInstance,
|
|
46
|
-
type
|
|
46
|
+
type ServerToClientMessage,
|
|
47
47
|
} from '@zhama/a2ui-core';
|
|
48
48
|
|
|
49
49
|
// Create components
|
|
@@ -52,7 +52,7 @@ const greeting = text({ path: '/user/name' }, { id: 'greeting' });
|
|
|
52
52
|
const root = column(['title', 'greeting'], { id: 'root' });
|
|
53
53
|
|
|
54
54
|
// Create messages
|
|
55
|
-
const messages =
|
|
55
|
+
const messages = createMessages({
|
|
56
56
|
surfaceId: SURFACE_IDS.CHAT,
|
|
57
57
|
components: [title, greeting, root],
|
|
58
58
|
dataModel: { user: { name: 'John' } },
|
|
@@ -69,10 +69,10 @@ You can import specific modules for tree-shaking:
|
|
|
69
69
|
|
|
70
70
|
```typescript
|
|
71
71
|
// Types only
|
|
72
|
-
import type { ComponentInstance,
|
|
72
|
+
import type { ComponentInstance, ServerToClientMessage } from '@zhama/a2ui-core/types';
|
|
73
73
|
|
|
74
74
|
// Builders only
|
|
75
|
-
import { text, column,
|
|
75
|
+
import { text, column, createMessages } from '@zhama/a2ui-core/builders';
|
|
76
76
|
|
|
77
77
|
// Validators only
|
|
78
78
|
import { validateMessage, validateMessages } from '@zhama/a2ui-core/validators';
|
|
@@ -103,7 +103,7 @@ list(children: ChildrenProperty, options?: ListOptions): ComponentInstance
|
|
|
103
103
|
card(childId: string, options?: CardOptions): ComponentInstance
|
|
104
104
|
tabs(items: TabItem[], options?: TabsOptions): ComponentInstance
|
|
105
105
|
divider(options?: DividerOptions): ComponentInstance
|
|
106
|
-
modal(
|
|
106
|
+
modal(triggerId: string, contentId: string, options?: ModalOptions): ComponentInstance
|
|
107
107
|
|
|
108
108
|
// Interactive components
|
|
109
109
|
button(childId: string, action: Action, options?: ButtonOptions): ComponentInstance
|
|
@@ -131,11 +131,11 @@ createSurface(surfaceId: string, catalogId?: string): CreateSurfaceMessage
|
|
|
131
131
|
updateComponents(surfaceId: string, components: ComponentInstance[]): UpdateComponentsMessage
|
|
132
132
|
updateDataModel(surfaceId: string, value: unknown, path?: string, op?: 'add' | 'replace' | 'remove'): UpdateDataModelMessage
|
|
133
133
|
deleteSurface(surfaceId: string): DeleteSurfaceMessage
|
|
134
|
-
|
|
134
|
+
createMessages(options): ServerToClientMessage[]
|
|
135
135
|
|
|
136
136
|
// Utilities
|
|
137
|
-
messagesToJsonl(messages:
|
|
138
|
-
jsonlToMessages(jsonl: string):
|
|
137
|
+
messagesToJsonl(messages: ServerToClientMessage[]): string
|
|
138
|
+
jsonlToMessages(jsonl: string): ServerToClientMessage[]
|
|
139
139
|
```
|
|
140
140
|
|
|
141
141
|
### Surface Module
|
|
@@ -154,7 +154,7 @@ SURFACE_IDS.NOTIFICATION // '@notification' - Notifications
|
|
|
154
154
|
// Surface creation functions
|
|
155
155
|
createA2UISurface(rootId: string, components: ComponentInstance[], surfaceId?: string): SurfaceResult
|
|
156
156
|
createA2UISurfaceWithData(rootId: string, components: ComponentInstance[], dataModel: DataObject, surfaceId?: string): SurfaceResult
|
|
157
|
-
createDeleteSurfaceMessage(surfaceId: string):
|
|
157
|
+
createDeleteSurfaceMessage(surfaceId: string): ServerToClientMessage
|
|
158
158
|
|
|
159
159
|
// Convenience functions
|
|
160
160
|
createChatSurface(rootId: string, components: ComponentInstance[]): SurfaceResult
|
|
@@ -178,7 +178,7 @@ normalizePath(path: string, pathMappings?: PathMappings): string
|
|
|
178
178
|
```typescript
|
|
179
179
|
validateMessage(message: ServerToClientMessage, options?: ValidationOptions): ValidationResult
|
|
180
180
|
validateMessages(messages: ServerToClientMessage[], options?: ValidationOptions): ValidationResult
|
|
181
|
-
|
|
181
|
+
validateMessage(message: ServerToClientMessage, options?: ValidationOptions): ValidationResult
|
|
182
182
|
```
|
|
183
183
|
|
|
184
184
|
### Utils
|
package/dist/builders/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
'use strict';var
|
|
2
|
-
`)}function
|
|
3
|
-
`).filter(e=>e.trim()).map(e=>JSON.parse(e))}var
|
|
1
|
+
'use strict';var g=0;function p(t="comp"){return `${t}_${Date.now()}_${g++}`}function b(){g=0;}function S(){return g}function M(t,e){let o={name:t};return e&&(o.context=e),{event:o}}function d(t,e={}){let{id:o=p("text"),weight:i,variant:n,accessibility:a}=e;return {id:o,component:"Text",text:t,...i!==void 0&&{weight:i},...n&&{variant:n},...a&&{accessibility:a}}}function T(t,e={}){let{id:o=p("image"),weight:i,fit:n,variant:a,accessibility:r}=e;return {id:o,component:"Image",url:t,...i!==void 0&&{weight:i},...n&&{fit:n},...a&&{variant:a},...r&&{accessibility:r}}}function v(t,e={}){let{id:o=p("icon"),weight:i,accessibility:n}=e;return {id:o,component:"Icon",name:t,...i!==void 0&&{weight:i},...n&&{accessibility:n}}}function A(t,e={}){let{id:o=p("video"),weight:i,accessibility:n}=e;return {id:o,component:"Video",url:t,...i!==void 0&&{weight:i},...n&&{accessibility:n}}}function k(t,e={}){let{id:o=p("audio"),weight:i,description:n,accessibility:a}=e;return {id:o,component:"AudioPlayer",url:t,...i!==void 0&&{weight:i},...n&&{description:n},...a&&{accessibility:a}}}function w(t,e={}){let{id:o=p("row"),weight:i,align:n,justify:a,accessibility:r}=e;return {id:o,component:"Row",children:t,...i!==void 0&&{weight:i},...n&&{align:n},...a&&{justify:a},...r&&{accessibility:r}}}function V(t,e={}){let{id:o=p("column"),weight:i,align:n,justify:a,accessibility:r}=e;return {id:o,component:"Column",children:t,...i!==void 0&&{weight:i},...n&&{align:n},...a&&{justify:a},...r&&{accessibility:r}}}function P(t,e={}){let{id:o=p("list"),weight:i,direction:n,align:a,accessibility:r}=e;return {id:o,component:"List",children:t,...i!==void 0&&{weight:i},...n&&{direction:n},...a&&{align:a},...r&&{accessibility:r}}}function L(t,e={}){let{id:o=p("card"),weight:i,accessibility:n}=e;return {id:o,component:"Card",child:t,...i!==void 0&&{weight:i},...n&&{accessibility:n}}}function R(t,e={}){let{id:o=p("tabs"),weight:i,accessibility:n}=e;return {id:o,component:"Tabs",tabs:t.map(a=>({title:a.title,child:a.childId})),...i!==void 0&&{weight:i},...n&&{accessibility:n}}}function F(t={}){let{id:e=p("divider"),weight:o,axis:i,accessibility:n}=t;return {id:e,component:"Divider",...o!==void 0&&{weight:o},...i&&{axis:i},...n&&{accessibility:n}}}function U(t,e,o={}){let{id:i=p("modal"),weight:n,accessibility:a}=o;return {id:i,component:"Modal",trigger:t,content:e,...n!==void 0&&{weight:n},...a&&{accessibility:a}}}function y(t,e,o={}){let{id:i=p("button"),weight:n,variant:a,checks:r,accessibility:s}=o;return {id:i,component:"Button",child:t,action:e,...n!==void 0&&{weight:n},...a&&{variant:a},...r&&r.length>0&&{checks:r},...s&&{accessibility:s}}}function B(t,e,o={}){let{id:i=p("checkbox"),weight:n,checks:a,accessibility:r}=o;return {id:i,component:"CheckBox",label:t,value:e,...n!==void 0&&{weight:n},...a&&a.length>0&&{checks:a},...r&&{accessibility:r}}}function E(t,e,o={}){let{id:i=p("textfield"),weight:n,variant:a,checks:r,accessibility:s}=o;return {id:i,component:"TextField",label:t,...e!==void 0&&{value:e},...n!==void 0&&{weight:n},...a&&{variant:a},...r&&r.length>0&&{checks:r},...s&&{accessibility:s}}}function _(t,e={}){let{id:o=p("datetime"),weight:i,enableDate:n,enableTime:a,min:r,max:s,label:c,checks:m,accessibility:u}=e;return {id:o,component:"DateTimeInput",value:t,...i!==void 0&&{weight:i},...n!==void 0&&{enableDate:n},...a!==void 0&&{enableTime:a},...r&&{min:r},...s&&{max:s},...c&&{label:c},...m&&m.length>0&&{checks:m},...u&&{accessibility:u}}}function j(t,e,o={}){let{id:i=p("choice"),weight:n,label:a,variant:r,checks:s,accessibility:c}=o;return {id:i,component:"ChoicePicker",options:t,value:e,...n!==void 0&&{weight:n},...a&&{label:a},...r&&{variant:r},...s&&s.length>0&&{checks:s},...c&&{accessibility:c}}}function N(t,e,o,i={}){let{id:n=p("slider"),weight:a,label:r,checks:s,accessibility:c}=i;return {id:n,component:"Slider",value:t,min:e,max:o,...a!==void 0&&{weight:a},...r&&{label:r},...s&&s.length>0&&{checks:s},...c&&{accessibility:c}}}function l(t,e,o={}){let{id:i=p("chart"),weight:n,title:a,xAxis:r,yAxis:s,legend:c,tooltip:m,height:u,width:f,echartsOption:x,accessibility:h}=o;return {id:i,component:"Chart",chartType:t,series:e,...n!==void 0&&{weight:n},...a&&{title:a},...r&&{xAxis:r},...s&&{yAxis:s},...c!==void 0&&{legend:c},...m!==void 0&&{tooltip:m},...u!==void 0&&{height:u},...f!==void 0&&{width:f},...x&&{echartsOption:x},...h&&{accessibility:h}}}function G(t,e={}){return l("line",t,e)}function $(t,e={}){return l("bar",t,e)}function J(t,e={}){return l("pie",t,e)}function z(t,e,o={}){let i=o.textId??p("btn_text"),n=d(t,{id:i}),a=y(i,e,o);return [n,a]}function H(t,e={}){return d(t,{...e,variant:"h1"})}function W(t,e={}){return d(t,{...e,variant:"h2"})}function q(t,e={}){return d(t,{...e,variant:"h3"})}function K(t,e={}){return d(t,{...e,variant:"h4"})}function Q(t,e={}){return d(t,{...e,variant:"h5"})}function X(t,e={}){return d(t,{...e,variant:"caption"})}function Y(t,e={}){return d(t,{...e,variant:"body"})}var C="https://a2ui.dev/specification/v0_9/standard_catalog.json";function O(t,e={}){let{catalogId:o=C,theme:i,sendDataModel:n}=e;return {createSurface:{surfaceId:t,catalogId:o,...i&&{theme:i},...n!==void 0&&{sendDataModel:n}}}}function D(t,e){return {updateComponents:{surfaceId:t,components:e}}}function I(t,e,o){return {updateDataModel:{surfaceId:t,...o&&{path:o},...e!==void 0&&{value:e}}}}function Z(t){return {deleteSurface:{surfaceId:t}}}function ee(t){let{surfaceId:e,catalogId:o,theme:i,sendDataModel:n,components:a,dataModel:r}=t,s=[O(e,{catalogId:o,theme:i,sendDataModel:n}),D(e,a)];return r&&s.push(I(e,r)),s}function te(t){return t.map(e=>JSON.stringify(e)).join(`
|
|
2
|
+
`)}function ne(t){return t.split(`
|
|
3
|
+
`).filter(e=>e.trim()).map(e=>JSON.parse(e))}var oe={};function ie(t,e={}){let o=t.replace(/\./g,"/");o.startsWith("/")||(o=`/${o}`);for(let[i,n]of Object.entries(e)){let a=new RegExp(`^/${i}(/|$)`);a.test(o)&&(o=o.replace(a,`/${n}$1`));}return o}exports.DEFAULT_PATH_MAPPINGS=oe;exports.audioPlayer=k;exports.barChart=$;exports.body=Y;exports.button=y;exports.caption=X;exports.card=L;exports.chart=l;exports.checkbox=B;exports.choicePicker=j;exports.column=V;exports.createMessages=ee;exports.createSurface=O;exports.dateTimeInput=_;exports.deleteSurface=Z;exports.divider=F;exports.eventAction=M;exports.generateId=p;exports.getIdCounter=S;exports.h1=H;exports.h2=W;exports.h3=q;exports.h4=K;exports.h5=Q;exports.icon=v;exports.image=T;exports.jsonlToMessages=ne;exports.lineChart=G;exports.list=P;exports.messagesToJsonl=te;exports.modal=U;exports.normalizePath=ie;exports.pieChart=J;exports.resetIdCounter=b;exports.row=w;exports.slider=N;exports.tabs=R;exports.text=d;exports.textButton=z;exports.textField=E;exports.updateComponents=D;exports.updateDataModel=I;exports.video=A;
|