@copilotkit/angular 0.6.0 → 2.0.0-rc.53
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/.attw.json +1 -2
- package/README.md +31 -133
- package/dist/README.md +31 -133
- package/dist/fesm2022/copilotkit-angular-generative-ui-chart.mjs +28 -0
- package/dist/fesm2022/copilotkit-angular-generative-ui-chart.mjs.map +1 -0
- package/dist/fesm2022/copilotkit-angular-generative-ui-icons.mjs +30 -0
- package/dist/fesm2022/copilotkit-angular-generative-ui-icons.mjs.map +1 -0
- package/dist/fesm2022/copilotkit-angular-generative-ui-map.mjs +28 -0
- package/dist/fesm2022/copilotkit-angular-generative-ui-map.mjs.map +1 -0
- package/dist/fesm2022/copilotkit-angular-generative-ui.mjs +11975 -0
- package/dist/fesm2022/copilotkit-angular-generative-ui.mjs.map +1 -0
- package/dist/fesm2022/copilotkit-angular-mcp-apps.mjs +43 -142
- package/dist/fesm2022/copilotkit-angular-mcp-apps.mjs.map +1 -1
- package/dist/fesm2022/copilotkit-angular.mjs +7422 -7467
- package/dist/fesm2022/copilotkit-angular.mjs.map +1 -1
- package/dist/types/copilotkit-angular-generative-ui-chart.d.ts +16 -0
- package/dist/types/copilotkit-angular-generative-ui-chart.d.ts.map +1 -0
- package/dist/types/copilotkit-angular-generative-ui-icons.d.ts +18 -0
- package/dist/types/copilotkit-angular-generative-ui-icons.d.ts.map +1 -0
- package/dist/types/copilotkit-angular-generative-ui-map.d.ts +16 -0
- package/dist/types/copilotkit-angular-generative-ui-map.d.ts.map +1 -0
- package/dist/types/copilotkit-angular-generative-ui.d.ts +8011 -0
- package/dist/types/copilotkit-angular-generative-ui.d.ts.map +1 -0
- package/dist/types/copilotkit-angular-mcp-apps.d.ts +234 -5560
- package/dist/types/copilotkit-angular-mcp-apps.d.ts.map +1 -1
- package/dist/types/copilotkit-angular.d.ts +1195 -820
- package/dist/types/copilotkit-angular.d.ts.map +1 -1
- package/package.json +54 -39
- package/scripts/generate-stylesheet.mjs +63 -0
- package/tsconfig.json +11 -1
- package/vitest.config.mts +6 -0
- package/dist/fesm2022/copilotkit-angular-a2ui.mjs +0 -1492
- package/dist/fesm2022/copilotkit-angular-a2ui.mjs.map +0 -1
- package/dist/styles.css +0 -2679
- package/dist/types/copilotkit-angular-a2ui.d.ts +0 -178
- package/dist/types/copilotkit-angular-a2ui.d.ts.map +0 -1
- package/scripts/scope-preflight.mjs +0 -100
|
@@ -1,1492 +0,0 @@
|
|
|
1
|
-
import { TextApi, ImageApi, IconApi, VideoApi, AudioPlayerApi, RowApi, ColumnApi, ListApi, CardApi, TabsApi, DividerApi, ModalApi, ButtonApi, TextFieldApi, CheckBoxApi, ChoicePickerApi, SliderApi, DateTimeInputApi, BASIC_FUNCTIONS } from '@a2ui/web_core/v0_9/basic_catalog';
|
|
2
|
-
import { A2uiMessageSchema, ComponentContext, GenericBinder, scrapeSchemaBehavior, MessageProcessor, Catalog } from '@a2ui/web_core/v0_9';
|
|
3
|
-
export { ActionSchema, ChildListSchema, DynamicBooleanSchema, DynamicNumberSchema, DynamicStringSchema } from '@a2ui/web_core/v0_9';
|
|
4
|
-
import { isPlatformBrowser, NgComponentOutlet } from '@angular/common';
|
|
5
|
-
import * as i0 from '@angular/core';
|
|
6
|
-
import { InjectionToken, inject, input, Injector, ElementRef, signal, computed, PLATFORM_ID, DestroyRef, effect, untracked, Component, output, Directive, reflectComponentType } from '@angular/core';
|
|
7
|
-
import { CopilotSlot } from '@copilotkit/angular';
|
|
8
|
-
|
|
9
|
-
function surfaceIdOf(message) {
|
|
10
|
-
if ("createSurface" in message)
|
|
11
|
-
return message.createSurface.surfaceId;
|
|
12
|
-
if ("updateComponents" in message)
|
|
13
|
-
return message.updateComponents.surfaceId;
|
|
14
|
-
if ("updateDataModel" in message)
|
|
15
|
-
return message.updateDataModel.surfaceId;
|
|
16
|
-
return message.deleteSurface.surfaceId;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Keeps the operations that are valid A2UI v0.9 messages; an operation without
|
|
20
|
-
* a `version` is read as v0.9. Every `createSurface` is pinned to `catalogId`:
|
|
21
|
-
* the renderer runs one catalog and web_core rejects surfaces naming an unknown
|
|
22
|
-
* one, so a stray id from the model would otherwise blank the surface. Anything
|
|
23
|
-
* else, such as a v0.8 message, is dropped with a warning.
|
|
24
|
-
*/
|
|
25
|
-
function normalizeA2UIOperations(operations, catalogId) {
|
|
26
|
-
return operations.flatMap((operation) => {
|
|
27
|
-
const message = {
|
|
28
|
-
version: "v0.9",
|
|
29
|
-
...(typeof operation === "object" ? operation : {}),
|
|
30
|
-
};
|
|
31
|
-
if (message["createSurface"] &&
|
|
32
|
-
typeof message["createSurface"] === "object") {
|
|
33
|
-
message["createSurface"] = { ...message["createSurface"], catalogId };
|
|
34
|
-
}
|
|
35
|
-
const parsed = A2uiMessageSchema.safeParse(message);
|
|
36
|
-
if (parsed.success)
|
|
37
|
-
return [parsed.data];
|
|
38
|
-
console.warn("[A2UI Angular] Dropped an operation that is not an A2UI v0.9 message:", operation, parsed.error.issues);
|
|
39
|
-
return [];
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Applies operations in order and returns the surfaces they address that
|
|
44
|
-
* still exist. A `createSurface` for an existing surface is skipped, and a
|
|
45
|
-
* surface addressed before it is created gets one with `catalogId` and `theme`.
|
|
46
|
-
*/
|
|
47
|
-
function applyA2UIOperations(processor, operations, catalogId, theme) {
|
|
48
|
-
const surfaceIds = new Set();
|
|
49
|
-
const exists = (surfaceId) => processor.model.getSurface(surfaceId) !== undefined;
|
|
50
|
-
for (const message of normalizeA2UIOperations(operations, catalogId)) {
|
|
51
|
-
const surfaceId = surfaceIdOf(message);
|
|
52
|
-
surfaceIds.add(surfaceId);
|
|
53
|
-
if ("createSurface" in message) {
|
|
54
|
-
if (!exists(surfaceId))
|
|
55
|
-
processor.processMessages([message]);
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
if ("deleteSurface" in message) {
|
|
59
|
-
if (exists(surfaceId))
|
|
60
|
-
processor.processMessages([message]);
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
if (!exists(surfaceId)) {
|
|
64
|
-
processor.processMessages([
|
|
65
|
-
{
|
|
66
|
-
version: "v0.9",
|
|
67
|
-
createSurface: { surfaceId, catalogId, theme: theme ?? {} },
|
|
68
|
-
},
|
|
69
|
-
]);
|
|
70
|
-
}
|
|
71
|
-
processor.processMessages([message]);
|
|
72
|
-
}
|
|
73
|
-
return [...surfaceIds]
|
|
74
|
-
.map((surfaceId) => processor.model.getSurface(surfaceId))
|
|
75
|
-
.filter((surface) => surface !== undefined);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function toChildRef(value, basePath) {
|
|
79
|
-
return typeof value === "string"
|
|
80
|
-
? { id: value, basePath }
|
|
81
|
-
: { id: value.id, basePath: value.basePath ?? basePath };
|
|
82
|
-
}
|
|
83
|
-
function isRecord(value) {
|
|
84
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* The binder resolves templated child lists to `{ id, basePath }` but leaves
|
|
88
|
-
* plain id arrays untouched. Normalize every child list in `value` to that
|
|
89
|
-
* shape; a missing child list becomes `[]`.
|
|
90
|
-
*/
|
|
91
|
-
function normalizeChildRefs(value, behavior, basePath) {
|
|
92
|
-
switch (behavior.type) {
|
|
93
|
-
case "STRUCTURAL":
|
|
94
|
-
return Array.isArray(value)
|
|
95
|
-
? value.map((item) => typeof item === "string" ? toChildRef(item, basePath) : item)
|
|
96
|
-
: [];
|
|
97
|
-
case "OBJECT": {
|
|
98
|
-
if (!isRecord(value))
|
|
99
|
-
return value;
|
|
100
|
-
const next = { ...value };
|
|
101
|
-
for (const [key, node] of Object.entries(behavior.shape)) {
|
|
102
|
-
if (key in value) {
|
|
103
|
-
next[key] = normalizeChildRefs(value[key], node, basePath);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return next;
|
|
107
|
-
}
|
|
108
|
-
case "ARRAY":
|
|
109
|
-
return Array.isArray(value)
|
|
110
|
-
? value.map((item) => normalizeChildRefs(item, behavior.element, basePath))
|
|
111
|
-
: value;
|
|
112
|
-
default:
|
|
113
|
-
return value;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const A2UI_COMPONENT_CONTEXT = new InjectionToken("A2UI_COMPONENT_CONTEXT");
|
|
118
|
-
/** Inject the {@link A2UIComponentContext} of the current catalog component. */
|
|
119
|
-
function injectA2UIComponentContext() {
|
|
120
|
-
return inject(A2UI_COMPONENT_CONTEXT);
|
|
121
|
-
}
|
|
122
|
-
/** @internal */
|
|
123
|
-
function createA2UIComponentContext(context, surface) {
|
|
124
|
-
return {
|
|
125
|
-
surfaceId: surface.id,
|
|
126
|
-
componentId: context.componentModel.id,
|
|
127
|
-
basePath: context.dataContext.path,
|
|
128
|
-
theme: (context.theme ?? {}),
|
|
129
|
-
surface,
|
|
130
|
-
dataContext: context.dataContext,
|
|
131
|
-
dispatch: (action) => context.dispatchAction(action),
|
|
132
|
-
set: (path, value) => context.dataContext.set(path, value),
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function isWebComponentImplementation(api) {
|
|
137
|
-
return (typeof api === "object" &&
|
|
138
|
-
api !== null &&
|
|
139
|
-
typeof api.tagName === "string" &&
|
|
140
|
-
typeof api.element === "function");
|
|
141
|
-
}
|
|
142
|
-
let missingCustomElementsReported = false;
|
|
143
|
-
/**
|
|
144
|
-
* Defines the entry's Custom Element. Registering the same element again is a
|
|
145
|
-
* no-op; a different element under the same tag name throws. Without
|
|
146
|
-
* `customElements` (server rendering) it reports once and does nothing.
|
|
147
|
-
*/
|
|
148
|
-
function registerUniversalElement(component) {
|
|
149
|
-
if (typeof customElements === "undefined") {
|
|
150
|
-
if (!missingCustomElementsReported) {
|
|
151
|
-
missingCustomElementsReported = true;
|
|
152
|
-
console.error(`Cannot register "${component.tagName}": \`customElements\` is not available in this ` +
|
|
153
|
-
"environment, so universal components will not render.");
|
|
154
|
-
}
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
const existing = customElements.get(component.tagName);
|
|
158
|
-
if (!existing) {
|
|
159
|
-
customElements.define(component.tagName, component.element);
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
if (existing !== component.element) {
|
|
163
|
-
throw new Error(`Custom element tag name collision for "${component.tagName}": ` +
|
|
164
|
-
`attempted to register ${component.element.name || "anonymous constructor"}, ` +
|
|
165
|
-
`but tag name is already registered with ${existing.name || "another constructor"}.`);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* @internal
|
|
171
|
-
* Bumped by the surface after each processed batch. Nodes read it to
|
|
172
|
-
* re-resolve their model synchronously; web_core delivers model events
|
|
173
|
-
* asynchronously, which is too late for a deterministic render.
|
|
174
|
-
*/
|
|
175
|
-
const A2UI_SURFACE_REVISION = new InjectionToken("A2UI_SURFACE_REVISION");
|
|
176
|
-
/**
|
|
177
|
-
* Sets every schema prop missing from the component's current properties to
|
|
178
|
-
* `undefined`: the binder omits props the agent has not sent and keeps
|
|
179
|
-
* removed ones from its previous snapshot. Publishing every schema prop also
|
|
180
|
-
* keeps the bound input names stable, so a streamed prop updates an input
|
|
181
|
-
* instead of recreating the component.
|
|
182
|
-
*/
|
|
183
|
-
function withCurrentProps(resolved, behavior, properties) {
|
|
184
|
-
if (behavior.type !== "OBJECT")
|
|
185
|
-
return resolved;
|
|
186
|
-
const props = { ...resolved };
|
|
187
|
-
for (const key of Object.keys(behavior.shape)) {
|
|
188
|
-
if (key in properties)
|
|
189
|
-
continue;
|
|
190
|
-
props[key] = undefined;
|
|
191
|
-
if (key === "checks")
|
|
192
|
-
props["isValid"] = props["validationErrors"] = undefined;
|
|
193
|
-
}
|
|
194
|
-
return props;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* @internal
|
|
198
|
-
* Renders one surface component with its registered Angular component,
|
|
199
|
-
* binding the binder-resolved props as a slot would, or with its Custom
|
|
200
|
-
* Element, which binds itself from the assigned `context`.
|
|
201
|
-
*/
|
|
202
|
-
class CopilotA2UINode {
|
|
203
|
-
surface = input.required(/* @ts-ignore */
|
|
204
|
-
...(ngDevMode ? [{ debugName: "surface" }] : /* istanbul ignore next */ []));
|
|
205
|
-
componentId = input.required(/* @ts-ignore */
|
|
206
|
-
...(ngDevMode ? [{ debugName: "componentId" }] : /* istanbul ignore next */ []));
|
|
207
|
-
basePath = input("/", /* @ts-ignore */
|
|
208
|
-
...(ngDevMode ? [{ debugName: "basePath" }] : /* istanbul ignore next */ []));
|
|
209
|
-
parentInjector = inject(Injector);
|
|
210
|
-
host = inject(ElementRef);
|
|
211
|
-
revision = inject(A2UI_SURFACE_REVISION);
|
|
212
|
-
props = signal({}, /* @ts-ignore */
|
|
213
|
-
...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
|
|
214
|
-
model = computed(() => {
|
|
215
|
-
this.revision();
|
|
216
|
-
return this.surface().componentsModel.get(this.componentId());
|
|
217
|
-
}, /* @ts-ignore */
|
|
218
|
-
...(ngDevMode ? [{ debugName: "model" }] : /* istanbul ignore next */ []));
|
|
219
|
-
implementation = computed(() => {
|
|
220
|
-
const model = this.model();
|
|
221
|
-
return model
|
|
222
|
-
? this.surface().catalog.components.get(model.type)
|
|
223
|
-
: undefined;
|
|
224
|
-
}, /* @ts-ignore */
|
|
225
|
-
...(ngDevMode ? [{ debugName: "implementation" }] : /* istanbul ignore next */ []));
|
|
226
|
-
/** The implementation when the entry is an Angular component. */
|
|
227
|
-
angularImplementation = computed(() => {
|
|
228
|
-
const implementation = this.implementation();
|
|
229
|
-
return implementation && !isWebComponentImplementation(implementation)
|
|
230
|
-
? implementation
|
|
231
|
-
: undefined;
|
|
232
|
-
}, /* @ts-ignore */
|
|
233
|
-
...(ngDevMode ? [{ debugName: "angularImplementation" }] : /* istanbul ignore next */ []));
|
|
234
|
-
componentContext = computed(() => {
|
|
235
|
-
const model = this.model();
|
|
236
|
-
return model && this.implementation()
|
|
237
|
-
? new ComponentContext(this.surface(), model.id, this.basePath())
|
|
238
|
-
: undefined;
|
|
239
|
-
}, /* @ts-ignore */
|
|
240
|
-
...(ngDevMode ? [{ debugName: "componentContext" }] : /* istanbul ignore next */ []));
|
|
241
|
-
/** Derived with the context, so a component never sees a stale one. */
|
|
242
|
-
injector = computed(() => {
|
|
243
|
-
const context = this.componentContext();
|
|
244
|
-
return context
|
|
245
|
-
? Injector.create({
|
|
246
|
-
providers: [
|
|
247
|
-
{
|
|
248
|
-
provide: A2UI_COMPONENT_CONTEXT,
|
|
249
|
-
useValue: createA2UIComponentContext(context, this.surface()),
|
|
250
|
-
},
|
|
251
|
-
],
|
|
252
|
-
parent: this.parentInjector,
|
|
253
|
-
})
|
|
254
|
-
: this.parentInjector;
|
|
255
|
-
}, /* @ts-ignore */
|
|
256
|
-
...(ngDevMode ? [{ debugName: "injector" }] : /* istanbul ignore next */ []));
|
|
257
|
-
constructor() {
|
|
258
|
-
// Custom Element entries: reuse the element while the tag is unchanged and
|
|
259
|
-
// hand it each new context, as the A2UI Angular renderer does. Elements
|
|
260
|
-
// only render in the browser; a server-rendered one would be duplicated on
|
|
261
|
-
// hydration.
|
|
262
|
-
const isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
|
|
263
|
-
let element;
|
|
264
|
-
const removeElement = () => {
|
|
265
|
-
element?.remove();
|
|
266
|
-
element = undefined;
|
|
267
|
-
};
|
|
268
|
-
inject(DestroyRef).onDestroy(removeElement);
|
|
269
|
-
effect((onCleanup) => {
|
|
270
|
-
const context = this.componentContext();
|
|
271
|
-
const implementation = this.implementation();
|
|
272
|
-
const surface = this.surface();
|
|
273
|
-
const basePath = this.basePath();
|
|
274
|
-
if (!isBrowser ||
|
|
275
|
-
!context ||
|
|
276
|
-
!isWebComponentImplementation(implementation)) {
|
|
277
|
-
untracked(removeElement);
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
// The element's own code runs untracked, so signals it reads cannot
|
|
281
|
-
// re-trigger this effect.
|
|
282
|
-
const target = untracked(() => {
|
|
283
|
-
registerUniversalElement(implementation);
|
|
284
|
-
if (element?.localName !== implementation.tagName) {
|
|
285
|
-
removeElement();
|
|
286
|
-
element = this.host.nativeElement.ownerDocument.createElement(implementation.tagName);
|
|
287
|
-
this.host.nativeElement.appendChild(element);
|
|
288
|
-
}
|
|
289
|
-
element.context = context;
|
|
290
|
-
return element;
|
|
291
|
-
});
|
|
292
|
-
// A fresh context per update, like the A2UI renderers, so elements that
|
|
293
|
-
// bind once per assignment still see every change.
|
|
294
|
-
const subscription = context.componentModel.onUpdated.subscribe((model) => {
|
|
295
|
-
target.context = new ComponentContext(surface, model.id, basePath);
|
|
296
|
-
});
|
|
297
|
-
onCleanup(() => subscription.unsubscribe());
|
|
298
|
-
});
|
|
299
|
-
effect((onCleanup) => {
|
|
300
|
-
const context = this.componentContext();
|
|
301
|
-
const implementation = this.angularImplementation();
|
|
302
|
-
if (!context || !implementation) {
|
|
303
|
-
untracked(() => this.props.set({}));
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
const binder = new GenericBinder(context, implementation.schema);
|
|
307
|
-
const behavior = scrapeSchemaBehavior(implementation.schema);
|
|
308
|
-
const publish = (next) => this.props.set(normalizeChildRefs(withCurrentProps(next ?? {}, behavior, context.componentModel.properties), behavior, context.dataContext.path));
|
|
309
|
-
// Subscribing connects the binder; its snapshot is then current.
|
|
310
|
-
// Unsubscribing the last listener disposes it.
|
|
311
|
-
const subscription = binder.subscribe(publish);
|
|
312
|
-
untracked(() => publish(binder.snapshot));
|
|
313
|
-
onCleanup(() => subscription.unsubscribe());
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UINode, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
317
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.0", type: CopilotA2UINode, isStandalone: true, selector: "copilot-a2ui-node", inputs: { surface: { classPropertyName: "surface", publicName: "surface", isSignal: true, isRequired: true, transformFunction: null }, componentId: { classPropertyName: "componentId", publicName: "componentId", isSignal: true, isRequired: true, transformFunction: null }, basePath: { classPropertyName: "basePath", publicName: "basePath", isSignal: true, isRequired: false, transformFunction: null } }, host: { styleAttribute: "display: contents" }, ngImport: i0, template: `
|
|
318
|
-
@if (model(); as model) {
|
|
319
|
-
@if (angularImplementation(); as implementation) {
|
|
320
|
-
<copilot-slot
|
|
321
|
-
style="display: contents"
|
|
322
|
-
[slot]="implementation.component"
|
|
323
|
-
[context]="props()"
|
|
324
|
-
[injector]="injector()"
|
|
325
|
-
/>
|
|
326
|
-
} @else if (!implementation()) {
|
|
327
|
-
<div
|
|
328
|
-
class="copilot-a2ui-node-unknown"
|
|
329
|
-
role="alert"
|
|
330
|
-
data-testid="a2ui-node-unknown"
|
|
331
|
-
>
|
|
332
|
-
Unknown component: {{ model.type }}
|
|
333
|
-
</div>
|
|
334
|
-
}
|
|
335
|
-
} @else {
|
|
336
|
-
<div
|
|
337
|
-
class="copilot-a2ui-node-placeholder"
|
|
338
|
-
data-testid="a2ui-node-placeholder"
|
|
339
|
-
aria-hidden="true"
|
|
340
|
-
></div>
|
|
341
|
-
}
|
|
342
|
-
`, isInline: true, styles: [".copilot-a2ui-node-placeholder{min-height:2rem;padding:12px 16px;border-radius:8px;background:linear-gradient(90deg,var(--a2ui-color-placeholder, #f3f4f6) 25%,var(--a2ui-color-placeholder-highlight, #e5e7eb) 50%,var(--a2ui-color-placeholder, #f3f4f6) 75%);background-size:200% 100%;animation:copilot-a2ui-shimmer 1.5s ease-in-out infinite}.copilot-a2ui-node-unknown{color:var(--a2ui-color-error, #b91c1c)}@keyframes copilot-a2ui-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}\n"], dependencies: [{ kind: "component", type: CopilotSlot, selector: "copilot-slot", inputs: ["slot", "context", "defaultComponent", "outputs", "injector"] }] });
|
|
343
|
-
}
|
|
344
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UINode, decorators: [{
|
|
345
|
-
type: Component,
|
|
346
|
-
args: [{ selector: "copilot-a2ui-node", imports: [CopilotSlot], host: { style: "display: contents" }, template: `
|
|
347
|
-
@if (model(); as model) {
|
|
348
|
-
@if (angularImplementation(); as implementation) {
|
|
349
|
-
<copilot-slot
|
|
350
|
-
style="display: contents"
|
|
351
|
-
[slot]="implementation.component"
|
|
352
|
-
[context]="props()"
|
|
353
|
-
[injector]="injector()"
|
|
354
|
-
/>
|
|
355
|
-
} @else if (!implementation()) {
|
|
356
|
-
<div
|
|
357
|
-
class="copilot-a2ui-node-unknown"
|
|
358
|
-
role="alert"
|
|
359
|
-
data-testid="a2ui-node-unknown"
|
|
360
|
-
>
|
|
361
|
-
Unknown component: {{ model.type }}
|
|
362
|
-
</div>
|
|
363
|
-
}
|
|
364
|
-
} @else {
|
|
365
|
-
<div
|
|
366
|
-
class="copilot-a2ui-node-placeholder"
|
|
367
|
-
data-testid="a2ui-node-placeholder"
|
|
368
|
-
aria-hidden="true"
|
|
369
|
-
></div>
|
|
370
|
-
}
|
|
371
|
-
`, styles: [".copilot-a2ui-node-placeholder{min-height:2rem;padding:12px 16px;border-radius:8px;background:linear-gradient(90deg,var(--a2ui-color-placeholder, #f3f4f6) 25%,var(--a2ui-color-placeholder-highlight, #e5e7eb) 50%,var(--a2ui-color-placeholder, #f3f4f6) 75%);background-size:200% 100%;animation:copilot-a2ui-shimmer 1.5s ease-in-out infinite}.copilot-a2ui-node-unknown{color:var(--a2ui-color-error, #b91c1c)}@keyframes copilot-a2ui-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}\n"] }]
|
|
372
|
-
}], ctorParameters: () => [], propDecorators: { surface: [{ type: i0.Input, args: [{ isSignal: true, alias: "surface", required: true }] }], componentId: [{ type: i0.Input, args: [{ isSignal: true, alias: "componentId", required: true }] }], basePath: [{ type: i0.Input, args: [{ isSignal: true, alias: "basePath", required: false }] }] } });
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* Renders A2UI operations with a {@link CopilotA2UICatalog}. Place it directly in
|
|
376
|
-
* a template to render operations outside the chat.
|
|
377
|
-
*
|
|
378
|
-
* @example
|
|
379
|
-
* ```html
|
|
380
|
-
* <copilot-a2ui-surface
|
|
381
|
-
* [operations]="operations()"
|
|
382
|
-
* [catalog]="dashboardCatalog"
|
|
383
|
-
* (action)="onAction($event)"
|
|
384
|
-
* />
|
|
385
|
-
* ```
|
|
386
|
-
*/
|
|
387
|
-
class CopilotA2UISurface {
|
|
388
|
-
/** A2UI operations in v0.9 or legacy shape. */
|
|
389
|
-
operations = input([], /* @ts-ignore */
|
|
390
|
-
...(ngDevMode ? [{ debugName: "operations" }] : /* istanbul ignore next */ []));
|
|
391
|
-
catalog = input.required(/* @ts-ignore */
|
|
392
|
-
...(ngDevMode ? [{ debugName: "catalog" }] : /* istanbul ignore next */ []));
|
|
393
|
-
/** Theme for surfaces the renderer creates itself. */
|
|
394
|
-
theme = input(/* @ts-ignore */
|
|
395
|
-
...(ngDevMode ? [undefined, { debugName: "theme" }] : /* istanbul ignore next */ []));
|
|
396
|
-
/** Shown until the first surface renders. */
|
|
397
|
-
loadingComponent = input(/* @ts-ignore */
|
|
398
|
-
...(ngDevMode ? [undefined, { debugName: "loadingComponent" }] : /* istanbul ignore next */ []));
|
|
399
|
-
action = output();
|
|
400
|
-
error = output();
|
|
401
|
-
/** Emits after each applied batch of operations. */
|
|
402
|
-
rendered = output();
|
|
403
|
-
surfaces = signal([], /* @ts-ignore */
|
|
404
|
-
...(ngDevMode ? [{ debugName: "surfaces" }] : /* istanbul ignore next */ []));
|
|
405
|
-
errorMessage = signal(null, /* @ts-ignore */
|
|
406
|
-
...(ngDevMode ? [{ debugName: "errorMessage" }] : /* istanbul ignore next */ []));
|
|
407
|
-
revision = inject(A2UI_SURFACE_REVISION);
|
|
408
|
-
processor = null;
|
|
409
|
-
processorCatalog = null;
|
|
410
|
-
lastOperationsHash = "";
|
|
411
|
-
appliedOperationsCount = 0;
|
|
412
|
-
constructor() {
|
|
413
|
-
effect(() => {
|
|
414
|
-
const catalog = this.catalog();
|
|
415
|
-
const operations = this.operations();
|
|
416
|
-
const theme = this.theme();
|
|
417
|
-
untracked(() => this.process(catalog, operations, theme));
|
|
418
|
-
});
|
|
419
|
-
}
|
|
420
|
-
ngOnDestroy() {
|
|
421
|
-
this.reset();
|
|
422
|
-
}
|
|
423
|
-
/** Drops the processor and everything rendered from it. */
|
|
424
|
-
reset() {
|
|
425
|
-
this.processor?.model.dispose();
|
|
426
|
-
this.processor = null;
|
|
427
|
-
this.processorCatalog = null;
|
|
428
|
-
this.lastOperationsHash = "";
|
|
429
|
-
this.appliedOperationsCount = 0;
|
|
430
|
-
this.surfaces.set([]);
|
|
431
|
-
}
|
|
432
|
-
getProcessor(catalog) {
|
|
433
|
-
if (!this.processor || this.processorCatalog !== catalog) {
|
|
434
|
-
this.reset();
|
|
435
|
-
this.processorCatalog = catalog;
|
|
436
|
-
this.processor = new MessageProcessor([catalog], (userAction) => {
|
|
437
|
-
this.action.emit({ userAction });
|
|
438
|
-
});
|
|
439
|
-
}
|
|
440
|
-
return this.processor;
|
|
441
|
-
}
|
|
442
|
-
process(catalog, operations, theme) {
|
|
443
|
-
if (operations.length === 0) {
|
|
444
|
-
// Start over, so the next operations cannot patch stale surfaces.
|
|
445
|
-
this.reset();
|
|
446
|
-
this.errorMessage.set(null);
|
|
447
|
-
return;
|
|
448
|
-
}
|
|
449
|
-
try {
|
|
450
|
-
if (this.processorCatalog !== catalog)
|
|
451
|
-
this.reset();
|
|
452
|
-
const hash = JSON.stringify({ operations, theme });
|
|
453
|
-
if (hash === this.lastOperationsHash)
|
|
454
|
-
return;
|
|
455
|
-
// Only retain the model when the previously applied history is unchanged.
|
|
456
|
-
const prefixHash = JSON.stringify({
|
|
457
|
-
operations: operations.slice(0, this.appliedOperationsCount),
|
|
458
|
-
theme,
|
|
459
|
-
});
|
|
460
|
-
if (prefixHash !== this.lastOperationsHash)
|
|
461
|
-
this.reset();
|
|
462
|
-
const processor = this.getProcessor(catalog);
|
|
463
|
-
applyA2UIOperations(processor, operations.slice(this.appliedOperationsCount), catalog.id, theme);
|
|
464
|
-
this.lastOperationsHash = hash;
|
|
465
|
-
this.appliedOperationsCount = operations.length;
|
|
466
|
-
this.revision.update((value) => value + 1);
|
|
467
|
-
this.surfaces.set([...processor.model.surfacesMap.values()]);
|
|
468
|
-
this.errorMessage.set(null);
|
|
469
|
-
this.rendered.emit();
|
|
470
|
-
}
|
|
471
|
-
catch (error) {
|
|
472
|
-
// A failed batch may have partially mutated the model; replay on recovery.
|
|
473
|
-
this.reset();
|
|
474
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
475
|
-
this.errorMessage.set(message);
|
|
476
|
-
this.error.emit({ error, message });
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UISurface, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
480
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.0", type: CopilotA2UISurface, isStandalone: true, selector: "copilot-a2ui-surface", inputs: { operations: { classPropertyName: "operations", publicName: "operations", isSignal: true, isRequired: false, transformFunction: null }, catalog: { classPropertyName: "catalog", publicName: "catalog", isSignal: true, isRequired: true, transformFunction: null }, theme: { classPropertyName: "theme", publicName: "theme", isSignal: true, isRequired: false, transformFunction: null }, loadingComponent: { classPropertyName: "loadingComponent", publicName: "loadingComponent", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { action: "action", error: "error", rendered: "rendered" }, providers: [{ provide: A2UI_SURFACE_REVISION, useFactory: () => signal(0) }], ngImport: i0, template: `
|
|
481
|
-
@if (errorMessage(); as message) {
|
|
482
|
-
<div class="copilot-a2ui-surface-error" role="alert" data-testid="a2ui-error">
|
|
483
|
-
A2UI render error: {{ message }}
|
|
484
|
-
</div>
|
|
485
|
-
} @else if (surfaces().length === 0) {
|
|
486
|
-
@if (loadingComponent(); as loading) {
|
|
487
|
-
<ng-container *ngComponentOutlet="loading" />
|
|
488
|
-
} @else {
|
|
489
|
-
<div
|
|
490
|
-
class="copilot-a2ui-surface-loading"
|
|
491
|
-
data-testid="a2ui-loading"
|
|
492
|
-
aria-busy="true"
|
|
493
|
-
>
|
|
494
|
-
<div class="copilot-a2ui-surface-loading-label">
|
|
495
|
-
<span
|
|
496
|
-
class="copilot-a2ui-surface-loading-dot"
|
|
497
|
-
data-testid="a2ui-loading-dot"
|
|
498
|
-
></span>
|
|
499
|
-
<span>Generating UI...</span>
|
|
500
|
-
</div>
|
|
501
|
-
@for (width of [80, 60, 40]; track $index) {
|
|
502
|
-
<div
|
|
503
|
-
class="copilot-a2ui-surface-loading-bar"
|
|
504
|
-
data-testid="a2ui-loading-bar"
|
|
505
|
-
[style.width.%]="width"
|
|
506
|
-
[style.animation-delay.ms]="$index * 150"
|
|
507
|
-
></div>
|
|
508
|
-
}
|
|
509
|
-
</div>
|
|
510
|
-
}
|
|
511
|
-
} @else {
|
|
512
|
-
<div class="copilot-a2ui-surfaces" data-testid="a2ui-activity-renderer">
|
|
513
|
-
@for (surface of surfaces(); track surface.id) {
|
|
514
|
-
<div
|
|
515
|
-
class="copilot-a2ui-surface-item"
|
|
516
|
-
[attr.data-surface-id]="surface.id"
|
|
517
|
-
>
|
|
518
|
-
<div
|
|
519
|
-
class="a2ui-surface"
|
|
520
|
-
[attr.data-surface-id]="surface.id"
|
|
521
|
-
[style.--a2ui-color-primary]="surface.theme?.primaryColor"
|
|
522
|
-
>
|
|
523
|
-
<copilot-a2ui-node [surface]="surface" componentId="root" />
|
|
524
|
-
</div>
|
|
525
|
-
</div>
|
|
526
|
-
}
|
|
527
|
-
</div>
|
|
528
|
-
}
|
|
529
|
-
`, isInline: true, styles: [":host{display:block;min-width:100%}.copilot-a2ui-surfaces{display:flex;min-height:0;flex:1;flex-direction:column}.copilot-a2ui-surface-item{display:flex;width:100%;flex-direction:column}.a2ui-surface{display:flex;flex:1}.copilot-a2ui-surface-error{border:1px solid var(--copilot-kit-error-border, #fecaca);border-radius:.5rem;background:var(--copilot-kit-error-background, #fef2f2);padding:.75rem;font-size:.875rem;color:var(--copilot-kit-error-text, #b91c1c)}.copilot-a2ui-surface-loading{display:flex;min-height:120px;flex-direction:column;gap:.5rem;border:1px solid var(--a2ui-color-placeholder, #f3f4f6);border-radius:.75rem;background:color-mix(in srgb,var(--a2ui-color-placeholder, #f9fafb) 50%,transparent);padding:1.25rem}.copilot-a2ui-surface-loading-label{display:flex;align-items:center;gap:.5rem;margin-bottom:.25rem;font-size:.75rem;font-weight:500;color:var(--a2ui-color-muted, #9ca3af)}.copilot-a2ui-surface-loading-dot{height:.75rem;width:.75rem;border-radius:9999px;background:var(--a2ui-color-placeholder-highlight, #e5e7eb);animation:copilot-a2ui-pulse 1.5s ease-in-out infinite}.copilot-a2ui-surface-loading-bar{height:.75rem;border-radius:.25rem;background:color-mix(in srgb,var(--a2ui-color-placeholder-highlight, #e5e7eb) 70%,transparent);animation:copilot-a2ui-pulse 1.5s ease-in-out infinite}@keyframes copilot-a2ui-pulse{0%,to{opacity:.4}50%{opacity:1}}\n"], dependencies: [{ kind: "directive", type: NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletEnvironmentInjector", "ngComponentOutletContent", "ngComponentOutletNgModule"], exportAs: ["ngComponentOutlet"] }, { kind: "component", type: CopilotA2UINode, selector: "copilot-a2ui-node", inputs: ["surface", "componentId", "basePath"] }] });
|
|
530
|
-
}
|
|
531
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UISurface, decorators: [{
|
|
532
|
-
type: Component,
|
|
533
|
-
args: [{ selector: "copilot-a2ui-surface", imports: [NgComponentOutlet, CopilotA2UINode], providers: [{ provide: A2UI_SURFACE_REVISION, useFactory: () => signal(0) }], template: `
|
|
534
|
-
@if (errorMessage(); as message) {
|
|
535
|
-
<div class="copilot-a2ui-surface-error" role="alert" data-testid="a2ui-error">
|
|
536
|
-
A2UI render error: {{ message }}
|
|
537
|
-
</div>
|
|
538
|
-
} @else if (surfaces().length === 0) {
|
|
539
|
-
@if (loadingComponent(); as loading) {
|
|
540
|
-
<ng-container *ngComponentOutlet="loading" />
|
|
541
|
-
} @else {
|
|
542
|
-
<div
|
|
543
|
-
class="copilot-a2ui-surface-loading"
|
|
544
|
-
data-testid="a2ui-loading"
|
|
545
|
-
aria-busy="true"
|
|
546
|
-
>
|
|
547
|
-
<div class="copilot-a2ui-surface-loading-label">
|
|
548
|
-
<span
|
|
549
|
-
class="copilot-a2ui-surface-loading-dot"
|
|
550
|
-
data-testid="a2ui-loading-dot"
|
|
551
|
-
></span>
|
|
552
|
-
<span>Generating UI...</span>
|
|
553
|
-
</div>
|
|
554
|
-
@for (width of [80, 60, 40]; track $index) {
|
|
555
|
-
<div
|
|
556
|
-
class="copilot-a2ui-surface-loading-bar"
|
|
557
|
-
data-testid="a2ui-loading-bar"
|
|
558
|
-
[style.width.%]="width"
|
|
559
|
-
[style.animation-delay.ms]="$index * 150"
|
|
560
|
-
></div>
|
|
561
|
-
}
|
|
562
|
-
</div>
|
|
563
|
-
}
|
|
564
|
-
} @else {
|
|
565
|
-
<div class="copilot-a2ui-surfaces" data-testid="a2ui-activity-renderer">
|
|
566
|
-
@for (surface of surfaces(); track surface.id) {
|
|
567
|
-
<div
|
|
568
|
-
class="copilot-a2ui-surface-item"
|
|
569
|
-
[attr.data-surface-id]="surface.id"
|
|
570
|
-
>
|
|
571
|
-
<div
|
|
572
|
-
class="a2ui-surface"
|
|
573
|
-
[attr.data-surface-id]="surface.id"
|
|
574
|
-
[style.--a2ui-color-primary]="surface.theme?.primaryColor"
|
|
575
|
-
>
|
|
576
|
-
<copilot-a2ui-node [surface]="surface" componentId="root" />
|
|
577
|
-
</div>
|
|
578
|
-
</div>
|
|
579
|
-
}
|
|
580
|
-
</div>
|
|
581
|
-
}
|
|
582
|
-
`, styles: [":host{display:block;min-width:100%}.copilot-a2ui-surfaces{display:flex;min-height:0;flex:1;flex-direction:column}.copilot-a2ui-surface-item{display:flex;width:100%;flex-direction:column}.a2ui-surface{display:flex;flex:1}.copilot-a2ui-surface-error{border:1px solid var(--copilot-kit-error-border, #fecaca);border-radius:.5rem;background:var(--copilot-kit-error-background, #fef2f2);padding:.75rem;font-size:.875rem;color:var(--copilot-kit-error-text, #b91c1c)}.copilot-a2ui-surface-loading{display:flex;min-height:120px;flex-direction:column;gap:.5rem;border:1px solid var(--a2ui-color-placeholder, #f3f4f6);border-radius:.75rem;background:color-mix(in srgb,var(--a2ui-color-placeholder, #f9fafb) 50%,transparent);padding:1.25rem}.copilot-a2ui-surface-loading-label{display:flex;align-items:center;gap:.5rem;margin-bottom:.25rem;font-size:.75rem;font-weight:500;color:var(--a2ui-color-muted, #9ca3af)}.copilot-a2ui-surface-loading-dot{height:.75rem;width:.75rem;border-radius:9999px;background:var(--a2ui-color-placeholder-highlight, #e5e7eb);animation:copilot-a2ui-pulse 1.5s ease-in-out infinite}.copilot-a2ui-surface-loading-bar{height:.75rem;border-radius:.25rem;background:color-mix(in srgb,var(--a2ui-color-placeholder-highlight, #e5e7eb) 70%,transparent);animation:copilot-a2ui-pulse 1.5s ease-in-out infinite}@keyframes copilot-a2ui-pulse{0%,to{opacity:.4}50%{opacity:1}}\n"] }]
|
|
583
|
-
}], ctorParameters: () => [], propDecorators: { operations: [{ type: i0.Input, args: [{ isSignal: true, alias: "operations", required: false }] }], catalog: [{ type: i0.Input, args: [{ isSignal: true, alias: "catalog", required: true }] }], theme: [{ type: i0.Input, args: [{ isSignal: true, alias: "theme", required: false }] }], loadingComponent: [{ type: i0.Input, args: [{ isSignal: true, alias: "loadingComponent", required: false }] }], action: [{ type: i0.Output, args: ["action"] }], error: [{ type: i0.Output, args: ["error"] }], rendered: [{ type: i0.Output, args: ["rendered"] }] } });
|
|
584
|
-
|
|
585
|
-
/**
|
|
586
|
-
* A catalog of Angular components. It carries its own renderer so the main
|
|
587
|
-
* entry point can mount it without importing this one.
|
|
588
|
-
*/
|
|
589
|
-
class CopilotA2UICatalog extends Catalog {
|
|
590
|
-
surfaceComponent = CopilotA2UISurface;
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
/**
|
|
594
|
-
* Base of the basic catalog components, as in the A2UI Angular renderer. Each
|
|
595
|
-
* component's host is its own box, so A2UI `weight` is its flex grow factor
|
|
596
|
-
* inside a Row or Column.
|
|
597
|
-
*/
|
|
598
|
-
class CopilotA2UIBasicComponent {
|
|
599
|
-
props = input.required(/* @ts-ignore */
|
|
600
|
-
...(ngDevMode ? [{ debugName: "props" }] : /* istanbul ignore next */ []));
|
|
601
|
-
weight = computed(() => this.props().weight ?? null, /* @ts-ignore */
|
|
602
|
-
...(ngDevMode ? [{ debugName: "weight" }] : /* istanbul ignore next */ []));
|
|
603
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UIBasicComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
604
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.0", type: CopilotA2UIBasicComponent, isStandalone: true, inputs: { props: { classPropertyName: "props", publicName: "props", isSignal: true, isRequired: true, transformFunction: null } }, host: { properties: { "style.flex": "weight()" } }, ngImport: i0 });
|
|
605
|
-
}
|
|
606
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UIBasicComponent, decorators: [{
|
|
607
|
-
type: Directive,
|
|
608
|
-
args: [{
|
|
609
|
-
host: { "[style.flex]": "weight()" },
|
|
610
|
-
}]
|
|
611
|
-
}], propDecorators: { props: [{ type: i0.Input, args: [{ isSignal: true, alias: "props", required: true }] }] } });
|
|
612
|
-
|
|
613
|
-
class CopilotA2UIAudioPlayer extends CopilotA2UIBasicComponent {
|
|
614
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UIAudioPlayer, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
615
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.0", type: CopilotA2UIAudioPlayer, isStandalone: true, selector: "copilot-a2ui-audio-player", usesInheritance: true, ngImport: i0, template: `
|
|
616
|
-
@if (props().description) {
|
|
617
|
-
<span class="description">{{ props().description }}</span>
|
|
618
|
-
}
|
|
619
|
-
<audio class="audio" controls [src]="props().url ?? ''"></audio>
|
|
620
|
-
`, isInline: true, styles: [":host{display:flex;flex-direction:column;gap:calc(var(--a2ui-spacing-m, 8px) / 2);width:100%}.description{font-size:var(--a2ui-font-size-xs, 12px);color:var(--a2ui-color-muted, #666)}.audio{width:100%;box-sizing:border-box}\n"] });
|
|
621
|
-
}
|
|
622
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UIAudioPlayer, decorators: [{
|
|
623
|
-
type: Component,
|
|
624
|
-
args: [{ selector: "copilot-a2ui-audio-player", template: `
|
|
625
|
-
@if (props().description) {
|
|
626
|
-
<span class="description">{{ props().description }}</span>
|
|
627
|
-
}
|
|
628
|
-
<audio class="audio" controls [src]="props().url ?? ''"></audio>
|
|
629
|
-
`, styles: [":host{display:flex;flex-direction:column;gap:calc(var(--a2ui-spacing-m, 8px) / 2);width:100%}.description{font-size:var(--a2ui-font-size-xs, 12px);color:var(--a2ui-color-muted, #666)}.audio{width:100%;box-sizing:border-box}\n"] }]
|
|
630
|
-
}] });
|
|
631
|
-
|
|
632
|
-
/**
|
|
633
|
-
* Renders a child of the current catalog component.
|
|
634
|
-
*
|
|
635
|
-
* @example
|
|
636
|
-
* ```html
|
|
637
|
-
* <copilot-a2ui-child [child]="props().child" />
|
|
638
|
-
* @for (child of props().children; track child.id) {
|
|
639
|
-
* <copilot-a2ui-child [child]="child" />
|
|
640
|
-
* }
|
|
641
|
-
* ```
|
|
642
|
-
*/
|
|
643
|
-
class CopilotA2UIChild {
|
|
644
|
-
/** A child id, or a `{ id, basePath }` reference from a resolved child list. */
|
|
645
|
-
child = input(/* @ts-ignore */
|
|
646
|
-
...(ngDevMode ? [undefined, { debugName: "child" }] : /* istanbul ignore next */ []));
|
|
647
|
-
context = injectA2UIComponentContext();
|
|
648
|
-
reference = computed(() => {
|
|
649
|
-
const child = this.child();
|
|
650
|
-
return child ? toChildRef(child, this.context.basePath) : undefined;
|
|
651
|
-
}, /* @ts-ignore */
|
|
652
|
-
...(ngDevMode ? [{ debugName: "reference" }] : /* istanbul ignore next */ []));
|
|
653
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UIChild, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
654
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.0", type: CopilotA2UIChild, isStandalone: true, selector: "copilot-a2ui-child", inputs: { child: { classPropertyName: "child", publicName: "child", isSignal: true, isRequired: false, transformFunction: null } }, host: { styleAttribute: "display: contents" }, ngImport: i0, template: `
|
|
655
|
-
@if (reference(); as reference) {
|
|
656
|
-
<copilot-a2ui-node
|
|
657
|
-
[surface]="context.surface"
|
|
658
|
-
[componentId]="reference.id"
|
|
659
|
-
[basePath]="reference.basePath"
|
|
660
|
-
/>
|
|
661
|
-
}
|
|
662
|
-
`, isInline: true, dependencies: [{ kind: "component", type: CopilotA2UINode, selector: "copilot-a2ui-node", inputs: ["surface", "componentId", "basePath"] }] });
|
|
663
|
-
}
|
|
664
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UIChild, decorators: [{
|
|
665
|
-
type: Component,
|
|
666
|
-
args: [{
|
|
667
|
-
selector: "copilot-a2ui-child",
|
|
668
|
-
imports: [CopilotA2UINode],
|
|
669
|
-
host: { style: "display: contents" },
|
|
670
|
-
template: `
|
|
671
|
-
@if (reference(); as reference) {
|
|
672
|
-
<copilot-a2ui-node
|
|
673
|
-
[surface]="context.surface"
|
|
674
|
-
[componentId]="reference.id"
|
|
675
|
-
[basePath]="reference.basePath"
|
|
676
|
-
/>
|
|
677
|
-
}
|
|
678
|
-
`,
|
|
679
|
-
}]
|
|
680
|
-
}], propDecorators: { child: [{ type: i0.Input, args: [{ isSignal: true, alias: "child", required: false }] }] } });
|
|
681
|
-
|
|
682
|
-
class CopilotA2UIButton extends CopilotA2UIBasicComponent {
|
|
683
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UIButton, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
684
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.0", type: CopilotA2UIButton, isStandalone: true, selector: "copilot-a2ui-button", usesInheritance: true, ngImport: i0, template: `
|
|
685
|
-
<button
|
|
686
|
-
type="button"
|
|
687
|
-
class="button"
|
|
688
|
-
[class.primary]="props().variant === 'primary'"
|
|
689
|
-
[class.borderless]="props().variant === 'borderless'"
|
|
690
|
-
[disabled]="props().isValid === false"
|
|
691
|
-
(click)="props().action?.()"
|
|
692
|
-
>
|
|
693
|
-
<copilot-a2ui-child [child]="props().child" />
|
|
694
|
-
</button>
|
|
695
|
-
`, isInline: true, styles: [":host{display:inline-flex;flex-direction:column}.button{display:inline-flex;align-items:center;justify-content:center;margin:var(--a2ui-spacing-m, 8px);padding:var(--a2ui-button-padding, 8px 16px);border:1px solid var(--a2ui-color-border, #ccc);border-radius:var(--a2ui-button-border-radius, 4px);box-sizing:border-box;background-color:var(--a2ui-color-surface, #fff);color:inherit;cursor:pointer}.primary{background-color:var( --a2ui-color-primary, var(--a2ui-primary-color, #007bff) );color:var(--a2ui-color-on-primary, #fff)}.borderless{border:none;background-color:transparent}\n"], dependencies: [{ kind: "component", type: CopilotA2UIChild, selector: "copilot-a2ui-child", inputs: ["child"] }] });
|
|
696
|
-
}
|
|
697
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UIButton, decorators: [{
|
|
698
|
-
type: Component,
|
|
699
|
-
args: [{ selector: "copilot-a2ui-button", imports: [CopilotA2UIChild], template: `
|
|
700
|
-
<button
|
|
701
|
-
type="button"
|
|
702
|
-
class="button"
|
|
703
|
-
[class.primary]="props().variant === 'primary'"
|
|
704
|
-
[class.borderless]="props().variant === 'borderless'"
|
|
705
|
-
[disabled]="props().isValid === false"
|
|
706
|
-
(click)="props().action?.()"
|
|
707
|
-
>
|
|
708
|
-
<copilot-a2ui-child [child]="props().child" />
|
|
709
|
-
</button>
|
|
710
|
-
`, styles: [":host{display:inline-flex;flex-direction:column}.button{display:inline-flex;align-items:center;justify-content:center;margin:var(--a2ui-spacing-m, 8px);padding:var(--a2ui-button-padding, 8px 16px);border:1px solid var(--a2ui-color-border, #ccc);border-radius:var(--a2ui-button-border-radius, 4px);box-sizing:border-box;background-color:var(--a2ui-color-surface, #fff);color:inherit;cursor:pointer}.primary{background-color:var( --a2ui-color-primary, var(--a2ui-primary-color, #007bff) );color:var(--a2ui-color-on-primary, #fff)}.borderless{border:none;background-color:transparent}\n"] }]
|
|
711
|
-
}] });
|
|
712
|
-
|
|
713
|
-
class CopilotA2UICard extends CopilotA2UIBasicComponent {
|
|
714
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UICard, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
715
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.0", type: CopilotA2UICard, isStandalone: true, selector: "copilot-a2ui-card", usesInheritance: true, ngImport: i0, template: `
|
|
716
|
-
<copilot-a2ui-child [child]="props().child" />
|
|
717
|
-
`, isInline: true, styles: [":host{display:block;margin:var(--a2ui-spacing-m, 8px);padding:var(--a2ui-card-padding, 16px);border:1px solid var(--a2ui-color-border, #ccc);border-radius:var(--a2ui-border-radius, 8px);box-sizing:border-box;background-color:var(--a2ui-color-surface, #fff);box-shadow:var(--a2ui-card-shadow, 0 2px 4px rgba(0, 0, 0, .1))}\n"], dependencies: [{ kind: "component", type: CopilotA2UIChild, selector: "copilot-a2ui-child", inputs: ["child"] }] });
|
|
718
|
-
}
|
|
719
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UICard, decorators: [{
|
|
720
|
-
type: Component,
|
|
721
|
-
args: [{ selector: "copilot-a2ui-card", imports: [CopilotA2UIChild], template: `
|
|
722
|
-
<copilot-a2ui-child [child]="props().child" />
|
|
723
|
-
`, styles: [":host{display:block;margin:var(--a2ui-spacing-m, 8px);padding:var(--a2ui-card-padding, 16px);border:1px solid var(--a2ui-color-border, #ccc);border-radius:var(--a2ui-border-radius, 8px);box-sizing:border-box;background-color:var(--a2ui-color-surface, #fff);box-shadow:var(--a2ui-card-shadow, 0 2px 4px rgba(0, 0, 0, .1))}\n"] }]
|
|
724
|
-
}] });
|
|
725
|
-
|
|
726
|
-
function mapJustify(justify) {
|
|
727
|
-
switch (justify) {
|
|
728
|
-
case "center":
|
|
729
|
-
return "center";
|
|
730
|
-
case "end":
|
|
731
|
-
return "flex-end";
|
|
732
|
-
case "spaceAround":
|
|
733
|
-
return "space-around";
|
|
734
|
-
case "spaceBetween":
|
|
735
|
-
return "space-between";
|
|
736
|
-
case "spaceEvenly":
|
|
737
|
-
return "space-evenly";
|
|
738
|
-
case "stretch":
|
|
739
|
-
return "stretch";
|
|
740
|
-
default:
|
|
741
|
-
return "flex-start";
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
function mapAlign(align) {
|
|
745
|
-
switch (align) {
|
|
746
|
-
case "start":
|
|
747
|
-
return "flex-start";
|
|
748
|
-
case "center":
|
|
749
|
-
return "center";
|
|
750
|
-
case "end":
|
|
751
|
-
return "flex-end";
|
|
752
|
-
default:
|
|
753
|
-
return "stretch";
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
let idCounter = 0;
|
|
757
|
-
/** A document-unique id for pairing labels with inputs. */
|
|
758
|
-
function uniqueId(prefix) {
|
|
759
|
-
idCounter += 1;
|
|
760
|
-
return `copilot-a2ui-${prefix}-${idCounter}`;
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
class CopilotA2UICheckBox extends CopilotA2UIBasicComponent {
|
|
764
|
-
inputId = uniqueId("checkbox");
|
|
765
|
-
error = computed(() => this.props().validationErrors?.[0], /* @ts-ignore */
|
|
766
|
-
...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
767
|
-
update(event) {
|
|
768
|
-
this.props().setValue(event.target.checked);
|
|
769
|
-
}
|
|
770
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UICheckBox, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
771
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.0", type: CopilotA2UICheckBox, isStandalone: true, selector: "copilot-a2ui-check-box", usesInheritance: true, ngImport: i0, template: `
|
|
772
|
-
<div class="control">
|
|
773
|
-
<input
|
|
774
|
-
type="checkbox"
|
|
775
|
-
class="checkbox"
|
|
776
|
-
[class.invalid]="error()"
|
|
777
|
-
[id]="inputId"
|
|
778
|
-
[checked]="!!props().value"
|
|
779
|
-
(change)="update($event)"
|
|
780
|
-
/>
|
|
781
|
-
@if (props().label) {
|
|
782
|
-
<label class="label" [class.invalid]="error()" [for]="inputId">
|
|
783
|
-
{{ props().label }}
|
|
784
|
-
</label>
|
|
785
|
-
}
|
|
786
|
-
</div>
|
|
787
|
-
@if (error(); as error) {
|
|
788
|
-
<span class="error">{{ error }}</span>
|
|
789
|
-
}
|
|
790
|
-
`, isInline: true, styles: [":host{display:flex;flex-direction:column;margin:var(--a2ui-spacing-m, 8px)}.control{display:flex;align-items:center;gap:var(--a2ui-spacing-m, 8px)}.checkbox{outline:none;cursor:pointer}.checkbox.invalid{outline:1px solid var(--a2ui-color-error, red)}.label{color:inherit;cursor:pointer}.label.invalid{color:var(--a2ui-color-error, red)}.error{margin-top:4px;font-size:var(--a2ui-font-size-xs, 12px);color:var(--a2ui-color-error, red)}\n"] });
|
|
791
|
-
}
|
|
792
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UICheckBox, decorators: [{
|
|
793
|
-
type: Component,
|
|
794
|
-
args: [{ selector: "copilot-a2ui-check-box", template: `
|
|
795
|
-
<div class="control">
|
|
796
|
-
<input
|
|
797
|
-
type="checkbox"
|
|
798
|
-
class="checkbox"
|
|
799
|
-
[class.invalid]="error()"
|
|
800
|
-
[id]="inputId"
|
|
801
|
-
[checked]="!!props().value"
|
|
802
|
-
(change)="update($event)"
|
|
803
|
-
/>
|
|
804
|
-
@if (props().label) {
|
|
805
|
-
<label class="label" [class.invalid]="error()" [for]="inputId">
|
|
806
|
-
{{ props().label }}
|
|
807
|
-
</label>
|
|
808
|
-
}
|
|
809
|
-
</div>
|
|
810
|
-
@if (error(); as error) {
|
|
811
|
-
<span class="error">{{ error }}</span>
|
|
812
|
-
}
|
|
813
|
-
`, styles: [":host{display:flex;flex-direction:column;margin:var(--a2ui-spacing-m, 8px)}.control{display:flex;align-items:center;gap:var(--a2ui-spacing-m, 8px)}.checkbox{outline:none;cursor:pointer}.checkbox.invalid{outline:1px solid var(--a2ui-color-error, red)}.label{color:inherit;cursor:pointer}.label.invalid{color:var(--a2ui-color-error, red)}.error{margin-top:4px;font-size:var(--a2ui-font-size-xs, 12px);color:var(--a2ui-color-error, red)}\n"] }]
|
|
814
|
-
}] });
|
|
815
|
-
|
|
816
|
-
class CopilotA2UIChoicePicker extends CopilotA2UIBasicComponent {
|
|
817
|
-
/** Per instance, so template-spawned pickers never share a radio group. */
|
|
818
|
-
groupName = uniqueId("choice");
|
|
819
|
-
filter = signal("", /* @ts-ignore */
|
|
820
|
-
...(ngDevMode ? [{ debugName: "filter" }] : /* istanbul ignore next */ []));
|
|
821
|
-
chips = computed(() => this.props().displayStyle === "chips", /* @ts-ignore */
|
|
822
|
-
...(ngDevMode ? [{ debugName: "chips" }] : /* istanbul ignore next */ []));
|
|
823
|
-
exclusive = computed(() => this.props().variant === "mutuallyExclusive", /* @ts-ignore */
|
|
824
|
-
...(ngDevMode ? [{ debugName: "exclusive" }] : /* istanbul ignore next */ []));
|
|
825
|
-
selected = computed(() => {
|
|
826
|
-
const value = this.props().value;
|
|
827
|
-
return Array.isArray(value) ? value : [];
|
|
828
|
-
}, /* @ts-ignore */
|
|
829
|
-
...(ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []));
|
|
830
|
-
options = computed(() => {
|
|
831
|
-
const { options, filterable } = this.props();
|
|
832
|
-
const filter = this.filter().toLowerCase();
|
|
833
|
-
return (options ?? []).filter((option) => !filterable ||
|
|
834
|
-
filter === "" ||
|
|
835
|
-
String(option.label).toLowerCase().includes(filter));
|
|
836
|
-
}, /* @ts-ignore */
|
|
837
|
-
...(ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []));
|
|
838
|
-
toggle(value) {
|
|
839
|
-
const selected = this.selected();
|
|
840
|
-
this.props().setValue(this.exclusive()
|
|
841
|
-
? [value]
|
|
842
|
-
: selected.includes(value)
|
|
843
|
-
? selected.filter((item) => item !== value)
|
|
844
|
-
: [...selected, value]);
|
|
845
|
-
}
|
|
846
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UIChoicePicker, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
847
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.0", type: CopilotA2UIChoicePicker, isStandalone: true, selector: "copilot-a2ui-choice-picker", usesInheritance: true, ngImport: i0, template: `
|
|
848
|
-
@if (props().label) {
|
|
849
|
-
<strong class="label">{{ props().label }}</strong>
|
|
850
|
-
}
|
|
851
|
-
@if (props().filterable) {
|
|
852
|
-
<input
|
|
853
|
-
#filterInput
|
|
854
|
-
type="text"
|
|
855
|
-
class="filter"
|
|
856
|
-
placeholder="Filter options..."
|
|
857
|
-
[value]="filter()"
|
|
858
|
-
(input)="filter.set(filterInput.value)"
|
|
859
|
-
/>
|
|
860
|
-
}
|
|
861
|
-
<div class="options" [class.chips]="chips()">
|
|
862
|
-
@for (option of options(); track option.value) {
|
|
863
|
-
@if (chips()) {
|
|
864
|
-
<button
|
|
865
|
-
type="button"
|
|
866
|
-
class="chip"
|
|
867
|
-
[class.selected]="selected().includes(option.value)"
|
|
868
|
-
(click)="toggle(option.value)"
|
|
869
|
-
>
|
|
870
|
-
{{ option.label }}
|
|
871
|
-
</button>
|
|
872
|
-
} @else {
|
|
873
|
-
<label class="option">
|
|
874
|
-
<input
|
|
875
|
-
[type]="exclusive() ? 'radio' : 'checkbox'"
|
|
876
|
-
[name]="exclusive() ? groupName : ''"
|
|
877
|
-
[checked]="selected().includes(option.value)"
|
|
878
|
-
(change)="toggle(option.value)"
|
|
879
|
-
/>
|
|
880
|
-
<span class="option-label">{{ option.label }}</span>
|
|
881
|
-
</label>
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
</div>
|
|
885
|
-
`, isInline: true, styles: [":host{display:flex;flex-direction:column;gap:var(--a2ui-spacing-m, 8px);width:100%}.label{font-size:var(--a2ui-font-size-s, 14px)}.filter{padding:4px 8px;background-color:var(--a2ui-color-input, Field);color:var(--a2ui-color-on-input, FieldText);border:1px solid var(--a2ui-color-border, #ccc);border-radius:var(--a2ui-border-radius, 8px)}.options{display:flex;flex-direction:column;flex-wrap:nowrap;gap:var(--a2ui-spacing-m, 8px)}.options.chips{flex-direction:row;flex-wrap:wrap}.chip{padding:4px 12px;border:1px solid var(--a2ui-color-border, #ccc);border-radius:var(--a2ui-chip-border-radius, 16px);background-color:var(--a2ui-color-surface, #fff);color:inherit;font-size:var(--a2ui-font-size-xs, 12px);cursor:pointer}.chip.selected{border:1px solid var(--a2ui-color-primary, var(--a2ui-primary-color, #007bff));background-color:var( --a2ui-color-primary, var(--a2ui-primary-color, #007bff) );color:var(--a2ui-color-on-primary, #fff)}.option{display:flex;align-items:center;gap:var(--a2ui-spacing-m, 8px);cursor:pointer}.option-label{font-size:var(--a2ui-font-size-s, 14px)}\n"] });
|
|
886
|
-
}
|
|
887
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UIChoicePicker, decorators: [{
|
|
888
|
-
type: Component,
|
|
889
|
-
args: [{ selector: "copilot-a2ui-choice-picker", template: `
|
|
890
|
-
@if (props().label) {
|
|
891
|
-
<strong class="label">{{ props().label }}</strong>
|
|
892
|
-
}
|
|
893
|
-
@if (props().filterable) {
|
|
894
|
-
<input
|
|
895
|
-
#filterInput
|
|
896
|
-
type="text"
|
|
897
|
-
class="filter"
|
|
898
|
-
placeholder="Filter options..."
|
|
899
|
-
[value]="filter()"
|
|
900
|
-
(input)="filter.set(filterInput.value)"
|
|
901
|
-
/>
|
|
902
|
-
}
|
|
903
|
-
<div class="options" [class.chips]="chips()">
|
|
904
|
-
@for (option of options(); track option.value) {
|
|
905
|
-
@if (chips()) {
|
|
906
|
-
<button
|
|
907
|
-
type="button"
|
|
908
|
-
class="chip"
|
|
909
|
-
[class.selected]="selected().includes(option.value)"
|
|
910
|
-
(click)="toggle(option.value)"
|
|
911
|
-
>
|
|
912
|
-
{{ option.label }}
|
|
913
|
-
</button>
|
|
914
|
-
} @else {
|
|
915
|
-
<label class="option">
|
|
916
|
-
<input
|
|
917
|
-
[type]="exclusive() ? 'radio' : 'checkbox'"
|
|
918
|
-
[name]="exclusive() ? groupName : ''"
|
|
919
|
-
[checked]="selected().includes(option.value)"
|
|
920
|
-
(change)="toggle(option.value)"
|
|
921
|
-
/>
|
|
922
|
-
<span class="option-label">{{ option.label }}</span>
|
|
923
|
-
</label>
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
</div>
|
|
927
|
-
`, styles: [":host{display:flex;flex-direction:column;gap:var(--a2ui-spacing-m, 8px);width:100%}.label{font-size:var(--a2ui-font-size-s, 14px)}.filter{padding:4px 8px;background-color:var(--a2ui-color-input, Field);color:var(--a2ui-color-on-input, FieldText);border:1px solid var(--a2ui-color-border, #ccc);border-radius:var(--a2ui-border-radius, 8px)}.options{display:flex;flex-direction:column;flex-wrap:nowrap;gap:var(--a2ui-spacing-m, 8px)}.options.chips{flex-direction:row;flex-wrap:wrap}.chip{padding:4px 12px;border:1px solid var(--a2ui-color-border, #ccc);border-radius:var(--a2ui-chip-border-radius, 16px);background-color:var(--a2ui-color-surface, #fff);color:inherit;font-size:var(--a2ui-font-size-xs, 12px);cursor:pointer}.chip.selected{border:1px solid var(--a2ui-color-primary, var(--a2ui-primary-color, #007bff));background-color:var( --a2ui-color-primary, var(--a2ui-primary-color, #007bff) );color:var(--a2ui-color-on-primary, #fff)}.option{display:flex;align-items:center;gap:var(--a2ui-spacing-m, 8px);cursor:pointer}.option-label{font-size:var(--a2ui-font-size-s, 14px)}\n"] }]
|
|
928
|
-
}] });
|
|
929
|
-
|
|
930
|
-
class CopilotA2UIColumn extends CopilotA2UIBasicComponent {
|
|
931
|
-
mapJustify = mapJustify;
|
|
932
|
-
mapAlign = mapAlign;
|
|
933
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UIColumn, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
934
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.0", type: CopilotA2UIColumn, isStandalone: true, selector: "copilot-a2ui-column", host: { properties: { "style.justify-content": "mapJustify(props().justify)", "style.align-items": "mapAlign(props().align)" } }, usesInheritance: true, ngImport: i0, template: `
|
|
935
|
-
@for (child of props().children; track $index) {
|
|
936
|
-
<copilot-a2ui-child [child]="child" />
|
|
937
|
-
}
|
|
938
|
-
`, isInline: true, styles: [":host{display:flex;flex-direction:column;gap:var(--a2ui-column-gap, var(--a2ui-spacing-m, 8px));width:100%}\n"], dependencies: [{ kind: "component", type: CopilotA2UIChild, selector: "copilot-a2ui-child", inputs: ["child"] }] });
|
|
939
|
-
}
|
|
940
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UIColumn, decorators: [{
|
|
941
|
-
type: Component,
|
|
942
|
-
args: [{ selector: "copilot-a2ui-column", imports: [CopilotA2UIChild], host: {
|
|
943
|
-
"[style.justify-content]": "mapJustify(props().justify)",
|
|
944
|
-
"[style.align-items]": "mapAlign(props().align)",
|
|
945
|
-
}, template: `
|
|
946
|
-
@for (child of props().children; track $index) {
|
|
947
|
-
<copilot-a2ui-child [child]="child" />
|
|
948
|
-
}
|
|
949
|
-
`, styles: [":host{display:flex;flex-direction:column;gap:var(--a2ui-column-gap, var(--a2ui-spacing-m, 8px));width:100%}\n"] }]
|
|
950
|
-
}] });
|
|
951
|
-
|
|
952
|
-
class CopilotA2UIDateTimeInput extends CopilotA2UIBasicComponent {
|
|
953
|
-
inputId = uniqueId("datetime");
|
|
954
|
-
type = computed(() => {
|
|
955
|
-
const { enableDate, enableTime } = this.props();
|
|
956
|
-
if (enableDate && !enableTime)
|
|
957
|
-
return "date";
|
|
958
|
-
if (!enableDate && enableTime)
|
|
959
|
-
return "time";
|
|
960
|
-
return "datetime-local";
|
|
961
|
-
}, /* @ts-ignore */
|
|
962
|
-
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
963
|
-
bound(value) {
|
|
964
|
-
return typeof value === "string" ? value : "";
|
|
965
|
-
}
|
|
966
|
-
update(event) {
|
|
967
|
-
this.props().setValue(event.target.value);
|
|
968
|
-
}
|
|
969
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UIDateTimeInput, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
970
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.0", type: CopilotA2UIDateTimeInput, isStandalone: true, selector: "copilot-a2ui-date-time-input", usesInheritance: true, ngImport: i0, template: `
|
|
971
|
-
@if (props().label) {
|
|
972
|
-
<label class="label" [for]="inputId">{{ props().label }}</label>
|
|
973
|
-
}
|
|
974
|
-
<input
|
|
975
|
-
class="input"
|
|
976
|
-
[id]="inputId"
|
|
977
|
-
[type]="type()"
|
|
978
|
-
[value]="props().value ?? ''"
|
|
979
|
-
[min]="bound(props().min)"
|
|
980
|
-
[max]="bound(props().max)"
|
|
981
|
-
(input)="update($event)"
|
|
982
|
-
/>
|
|
983
|
-
`, isInline: true, styles: [":host{display:flex;flex-direction:column;gap:calc(var(--a2ui-spacing-m, 8px) / 2);width:100%}.label{font-size:var(--a2ui-font-size-s, 14px);font-weight:700}.input{width:100%;padding:var(--a2ui-input-padding, 8px);border:1px solid var(--a2ui-color-border, #ccc);border-radius:var(--a2ui-border-radius, 8px);box-sizing:border-box;background-color:var(--a2ui-color-input, Field);color:var(--a2ui-color-on-input, FieldText)}\n"] });
|
|
984
|
-
}
|
|
985
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UIDateTimeInput, decorators: [{
|
|
986
|
-
type: Component,
|
|
987
|
-
args: [{ selector: "copilot-a2ui-date-time-input", template: `
|
|
988
|
-
@if (props().label) {
|
|
989
|
-
<label class="label" [for]="inputId">{{ props().label }}</label>
|
|
990
|
-
}
|
|
991
|
-
<input
|
|
992
|
-
class="input"
|
|
993
|
-
[id]="inputId"
|
|
994
|
-
[type]="type()"
|
|
995
|
-
[value]="props().value ?? ''"
|
|
996
|
-
[min]="bound(props().min)"
|
|
997
|
-
[max]="bound(props().max)"
|
|
998
|
-
(input)="update($event)"
|
|
999
|
-
/>
|
|
1000
|
-
`, styles: [":host{display:flex;flex-direction:column;gap:calc(var(--a2ui-spacing-m, 8px) / 2);width:100%}.label{font-size:var(--a2ui-font-size-s, 14px);font-weight:700}.input{width:100%;padding:var(--a2ui-input-padding, 8px);border:1px solid var(--a2ui-color-border, #ccc);border-radius:var(--a2ui-border-radius, 8px);box-sizing:border-box;background-color:var(--a2ui-color-input, Field);color:var(--a2ui-color-on-input, FieldText)}\n"] }]
|
|
1001
|
-
}] });
|
|
1002
|
-
|
|
1003
|
-
class CopilotA2UIDivider extends CopilotA2UIBasicComponent {
|
|
1004
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UIDivider, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1005
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.0", type: CopilotA2UIDivider, isStandalone: true, selector: "copilot-a2ui-divider", host: { attributes: { "role": "separator" }, properties: { "class.vertical": "props().axis === 'vertical'" } }, usesInheritance: true, ngImport: i0, template: "", isInline: true, styles: [":host{display:block;width:100%;height:1px;margin:var(--a2ui-spacing-m, 8px) 0;border:none;background-color:var(--a2ui-color-border, #ccc)}:host(.vertical){width:1px;height:100%;margin:0 var(--a2ui-spacing-m, 8px)}\n"] });
|
|
1006
|
-
}
|
|
1007
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UIDivider, decorators: [{
|
|
1008
|
-
type: Component,
|
|
1009
|
-
args: [{ selector: "copilot-a2ui-divider", host: {
|
|
1010
|
-
role: "separator",
|
|
1011
|
-
"[class.vertical]": "props().axis === 'vertical'",
|
|
1012
|
-
}, template: "", styles: [":host{display:block;width:100%;height:1px;margin:var(--a2ui-spacing-m, 8px) 0;border:none;background-color:var(--a2ui-color-border, #ccc)}:host(.vertical){width:1px;height:100%;margin:0 var(--a2ui-spacing-m, 8px)}\n"] }]
|
|
1013
|
-
}] });
|
|
1014
|
-
|
|
1015
|
-
/** Renders a Material Symbols ligature; the app loads the icon font. */
|
|
1016
|
-
class CopilotA2UIIcon extends CopilotA2UIBasicComponent {
|
|
1017
|
-
name = computed(() => {
|
|
1018
|
-
const name = this.props().name;
|
|
1019
|
-
return typeof name === "string"
|
|
1020
|
-
? name
|
|
1021
|
-
: name?.path;
|
|
1022
|
-
}, /* @ts-ignore */
|
|
1023
|
-
...(ngDevMode ? [{ debugName: "name" }] : /* istanbul ignore next */ []));
|
|
1024
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UIIcon, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1025
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.0", type: CopilotA2UIIcon, isStandalone: true, selector: "copilot-a2ui-icon", usesInheritance: true, ngImport: i0, template: `
|
|
1026
|
-
<span class="material-symbols-outlined icon">{{ name() }}</span>
|
|
1027
|
-
`, isInline: true, styles: [":host{display:inline-flex}.icon{display:inline-flex;align-items:center;justify-content:center;width:var(--a2ui-icon-size, 24px);height:var(--a2ui-icon-size, 24px);box-sizing:border-box;font-size:var(--a2ui-icon-size, 24px)}\n"] });
|
|
1028
|
-
}
|
|
1029
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UIIcon, decorators: [{
|
|
1030
|
-
type: Component,
|
|
1031
|
-
args: [{ selector: "copilot-a2ui-icon", template: `
|
|
1032
|
-
<span class="material-symbols-outlined icon">{{ name() }}</span>
|
|
1033
|
-
`, styles: [":host{display:inline-flex}.icon{display:inline-flex;align-items:center;justify-content:center;width:var(--a2ui-icon-size, 24px);height:var(--a2ui-icon-size, 24px);box-sizing:border-box;font-size:var(--a2ui-icon-size, 24px)}\n"] }]
|
|
1034
|
-
}] });
|
|
1035
|
-
|
|
1036
|
-
class CopilotA2UIImage extends CopilotA2UIBasicComponent {
|
|
1037
|
-
fit = computed(() => {
|
|
1038
|
-
const { variant, fit } = this.props();
|
|
1039
|
-
if (variant === "header")
|
|
1040
|
-
return "cover";
|
|
1041
|
-
return fit === "scaleDown" ? "scale-down" : fit || "fill";
|
|
1042
|
-
}, /* @ts-ignore */
|
|
1043
|
-
...(ngDevMode ? [{ debugName: "fit" }] : /* istanbul ignore next */ []));
|
|
1044
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UIImage, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1045
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.0", type: CopilotA2UIImage, isStandalone: true, selector: "copilot-a2ui-image", usesInheritance: true, ngImport: i0, template: `
|
|
1046
|
-
<img
|
|
1047
|
-
class="image"
|
|
1048
|
-
[class]="'variant-' + (props().variant ?? 'default')"
|
|
1049
|
-
[src]="props().url ?? ''"
|
|
1050
|
-
[alt]="props().description ?? ''"
|
|
1051
|
-
[style.object-fit]="fit()"
|
|
1052
|
-
/>
|
|
1053
|
-
`, isInline: true, styles: [":host{display:block}.image{display:block;width:100%;height:auto;box-sizing:border-box}.variant-icon{width:24px;height:24px}.variant-avatar{width:40px;height:40px;border-radius:50%}.variant-smallFeature{max-width:100px}.variant-largeFeature{max-height:400px}.variant-header{height:200px}\n"] });
|
|
1054
|
-
}
|
|
1055
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UIImage, decorators: [{
|
|
1056
|
-
type: Component,
|
|
1057
|
-
args: [{ selector: "copilot-a2ui-image", template: `
|
|
1058
|
-
<img
|
|
1059
|
-
class="image"
|
|
1060
|
-
[class]="'variant-' + (props().variant ?? 'default')"
|
|
1061
|
-
[src]="props().url ?? ''"
|
|
1062
|
-
[alt]="props().description ?? ''"
|
|
1063
|
-
[style.object-fit]="fit()"
|
|
1064
|
-
/>
|
|
1065
|
-
`, styles: [":host{display:block}.image{display:block;width:100%;height:auto;box-sizing:border-box}.variant-icon{width:24px;height:24px}.variant-avatar{width:40px;height:40px;border-radius:50%}.variant-smallFeature{max-width:100px}.variant-largeFeature{max-height:400px}.variant-header{height:200px}\n"] }]
|
|
1066
|
-
}] });
|
|
1067
|
-
|
|
1068
|
-
class CopilotA2UIList extends CopilotA2UIBasicComponent {
|
|
1069
|
-
mapAlign = mapAlign;
|
|
1070
|
-
horizontal = computed(() => this.props().direction === "horizontal", /* @ts-ignore */
|
|
1071
|
-
...(ngDevMode ? [{ debugName: "horizontal" }] : /* istanbul ignore next */ []));
|
|
1072
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UIList, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1073
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.0", type: CopilotA2UIList, isStandalone: true, selector: "copilot-a2ui-list", host: { properties: { "class.horizontal": "horizontal()", "style.align-items": "mapAlign(props().align)" } }, usesInheritance: true, ngImport: i0, template: `
|
|
1074
|
-
@for (child of props().children; track $index) {
|
|
1075
|
-
<copilot-a2ui-child [child]="child" />
|
|
1076
|
-
}
|
|
1077
|
-
`, isInline: true, styles: [":host{display:flex;flex-direction:column;gap:var(--a2ui-list-gap, var(--a2ui-spacing-m, 8px));overflow-x:hidden;overflow-y:auto;width:100%}:host(.horizontal){flex-direction:row;overflow-x:auto;overflow-y:hidden}\n"], dependencies: [{ kind: "component", type: CopilotA2UIChild, selector: "copilot-a2ui-child", inputs: ["child"] }] });
|
|
1078
|
-
}
|
|
1079
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UIList, decorators: [{
|
|
1080
|
-
type: Component,
|
|
1081
|
-
args: [{ selector: "copilot-a2ui-list", imports: [CopilotA2UIChild], host: {
|
|
1082
|
-
"[class.horizontal]": "horizontal()",
|
|
1083
|
-
"[style.align-items]": "mapAlign(props().align)",
|
|
1084
|
-
}, template: `
|
|
1085
|
-
@for (child of props().children; track $index) {
|
|
1086
|
-
<copilot-a2ui-child [child]="child" />
|
|
1087
|
-
}
|
|
1088
|
-
`, styles: [":host{display:flex;flex-direction:column;gap:var(--a2ui-list-gap, var(--a2ui-spacing-m, 8px));overflow-x:hidden;overflow-y:auto;width:100%}:host(.horizontal){flex-direction:row;overflow-x:auto;overflow-y:hidden}\n"] }]
|
|
1089
|
-
}] });
|
|
1090
|
-
|
|
1091
|
-
class CopilotA2UIModal extends CopilotA2UIBasicComponent {
|
|
1092
|
-
open = signal(false, /* @ts-ignore */
|
|
1093
|
-
...(ngDevMode ? [{ debugName: "open" }] : /* istanbul ignore next */ []));
|
|
1094
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UIModal, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1095
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.0", type: CopilotA2UIModal, isStandalone: true, selector: "copilot-a2ui-modal", usesInheritance: true, ngImport: i0, template: `
|
|
1096
|
-
<div (click)="open.set(true)">
|
|
1097
|
-
<copilot-a2ui-child [child]="props().trigger" />
|
|
1098
|
-
</div>
|
|
1099
|
-
@if (open()) {
|
|
1100
|
-
<div class="backdrop" (click)="open.set(false)">
|
|
1101
|
-
<div
|
|
1102
|
-
class="dialog"
|
|
1103
|
-
role="dialog"
|
|
1104
|
-
aria-modal="true"
|
|
1105
|
-
(click)="$event.stopPropagation()"
|
|
1106
|
-
>
|
|
1107
|
-
<div class="dialog-header">
|
|
1108
|
-
<button
|
|
1109
|
-
type="button"
|
|
1110
|
-
class="close"
|
|
1111
|
-
aria-label="Close"
|
|
1112
|
-
(click)="open.set(false)"
|
|
1113
|
-
>
|
|
1114
|
-
×
|
|
1115
|
-
</button>
|
|
1116
|
-
</div>
|
|
1117
|
-
<div class="dialog-content">
|
|
1118
|
-
<copilot-a2ui-child [child]="props().content" />
|
|
1119
|
-
</div>
|
|
1120
|
-
</div>
|
|
1121
|
-
</div>
|
|
1122
|
-
}
|
|
1123
|
-
`, isInline: true, styles: [":host{display:inline-block}.backdrop{position:fixed;inset:0;z-index:var(--a2ui-modal-z-index, 1000);display:flex;align-items:center;justify-content:center;background-color:var(--a2ui-modal-backdrop, rgba(0, 0, 0, .5))}.dialog{display:flex;flex-direction:column;max-width:90%;max-height:90%;overflow:auto;padding:var(--a2ui-modal-padding, 24px);border-radius:var(--a2ui-border-radius, 8px);background-color:var(--a2ui-color-surface, #fff)}.dialog-header{display:flex;justify-content:flex-end}.close{padding:4px;border:none;background:none;font-size:20px;cursor:pointer}.dialog-content{flex:1}\n"], dependencies: [{ kind: "component", type: CopilotA2UIChild, selector: "copilot-a2ui-child", inputs: ["child"] }] });
|
|
1124
|
-
}
|
|
1125
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UIModal, decorators: [{
|
|
1126
|
-
type: Component,
|
|
1127
|
-
args: [{ selector: "copilot-a2ui-modal", imports: [CopilotA2UIChild], template: `
|
|
1128
|
-
<div (click)="open.set(true)">
|
|
1129
|
-
<copilot-a2ui-child [child]="props().trigger" />
|
|
1130
|
-
</div>
|
|
1131
|
-
@if (open()) {
|
|
1132
|
-
<div class="backdrop" (click)="open.set(false)">
|
|
1133
|
-
<div
|
|
1134
|
-
class="dialog"
|
|
1135
|
-
role="dialog"
|
|
1136
|
-
aria-modal="true"
|
|
1137
|
-
(click)="$event.stopPropagation()"
|
|
1138
|
-
>
|
|
1139
|
-
<div class="dialog-header">
|
|
1140
|
-
<button
|
|
1141
|
-
type="button"
|
|
1142
|
-
class="close"
|
|
1143
|
-
aria-label="Close"
|
|
1144
|
-
(click)="open.set(false)"
|
|
1145
|
-
>
|
|
1146
|
-
×
|
|
1147
|
-
</button>
|
|
1148
|
-
</div>
|
|
1149
|
-
<div class="dialog-content">
|
|
1150
|
-
<copilot-a2ui-child [child]="props().content" />
|
|
1151
|
-
</div>
|
|
1152
|
-
</div>
|
|
1153
|
-
</div>
|
|
1154
|
-
}
|
|
1155
|
-
`, styles: [":host{display:inline-block}.backdrop{position:fixed;inset:0;z-index:var(--a2ui-modal-z-index, 1000);display:flex;align-items:center;justify-content:center;background-color:var(--a2ui-modal-backdrop, rgba(0, 0, 0, .5))}.dialog{display:flex;flex-direction:column;max-width:90%;max-height:90%;overflow:auto;padding:var(--a2ui-modal-padding, 24px);border-radius:var(--a2ui-border-radius, 8px);background-color:var(--a2ui-color-surface, #fff)}.dialog-header{display:flex;justify-content:flex-end}.close{padding:4px;border:none;background:none;font-size:20px;cursor:pointer}.dialog-content{flex:1}\n"] }]
|
|
1156
|
-
}] });
|
|
1157
|
-
|
|
1158
|
-
class CopilotA2UIRow extends CopilotA2UIBasicComponent {
|
|
1159
|
-
mapJustify = mapJustify;
|
|
1160
|
-
mapAlign = mapAlign;
|
|
1161
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UIRow, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1162
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.0", type: CopilotA2UIRow, isStandalone: true, selector: "copilot-a2ui-row", host: { properties: { "style.justify-content": "mapJustify(props().justify)", "style.align-items": "mapAlign(props().align)" } }, usesInheritance: true, ngImport: i0, template: `
|
|
1163
|
-
@for (child of props().children; track $index) {
|
|
1164
|
-
<copilot-a2ui-child [child]="child" />
|
|
1165
|
-
}
|
|
1166
|
-
`, isInline: true, styles: [":host{display:flex;flex-direction:row;gap:var(--a2ui-row-gap, var(--a2ui-spacing-m, 8px))}\n"], dependencies: [{ kind: "component", type: CopilotA2UIChild, selector: "copilot-a2ui-child", inputs: ["child"] }] });
|
|
1167
|
-
}
|
|
1168
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UIRow, decorators: [{
|
|
1169
|
-
type: Component,
|
|
1170
|
-
args: [{ selector: "copilot-a2ui-row", imports: [CopilotA2UIChild], host: {
|
|
1171
|
-
"[style.justify-content]": "mapJustify(props().justify)",
|
|
1172
|
-
"[style.align-items]": "mapAlign(props().align)",
|
|
1173
|
-
}, template: `
|
|
1174
|
-
@for (child of props().children; track $index) {
|
|
1175
|
-
<copilot-a2ui-child [child]="child" />
|
|
1176
|
-
}
|
|
1177
|
-
`, styles: [":host{display:flex;flex-direction:row;gap:var(--a2ui-row-gap, var(--a2ui-spacing-m, 8px))}\n"] }]
|
|
1178
|
-
}] });
|
|
1179
|
-
|
|
1180
|
-
class CopilotA2UISlider extends CopilotA2UIBasicComponent {
|
|
1181
|
-
inputId = uniqueId("slider");
|
|
1182
|
-
update(event) {
|
|
1183
|
-
this.props().setValue(Number(event.target.value));
|
|
1184
|
-
}
|
|
1185
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UISlider, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1186
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.0", type: CopilotA2UISlider, isStandalone: true, selector: "copilot-a2ui-slider", usesInheritance: true, ngImport: i0, template: `
|
|
1187
|
-
<div class="header">
|
|
1188
|
-
@if (props().label) {
|
|
1189
|
-
<label class="label" [for]="inputId">{{ props().label }}</label>
|
|
1190
|
-
}
|
|
1191
|
-
<span class="value">{{ props().value }}</span>
|
|
1192
|
-
</div>
|
|
1193
|
-
<input
|
|
1194
|
-
type="range"
|
|
1195
|
-
class="range"
|
|
1196
|
-
[id]="inputId"
|
|
1197
|
-
[min]="props().min ?? 0"
|
|
1198
|
-
[max]="props().max"
|
|
1199
|
-
[value]="props().value ?? 0"
|
|
1200
|
-
(input)="update($event)"
|
|
1201
|
-
/>
|
|
1202
|
-
`, isInline: true, styles: [":host{display:flex;flex-direction:column;gap:calc(var(--a2ui-spacing-m, 8px) / 2);width:100%}.header{display:flex;justify-content:space-between}.label{font-size:var(--a2ui-font-size-s, 14px);font-weight:700}.value{font-size:var(--a2ui-font-size-xs, 12px);color:var(--a2ui-color-muted, #666)}.range{width:100%;cursor:pointer}\n"] });
|
|
1203
|
-
}
|
|
1204
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UISlider, decorators: [{
|
|
1205
|
-
type: Component,
|
|
1206
|
-
args: [{ selector: "copilot-a2ui-slider", template: `
|
|
1207
|
-
<div class="header">
|
|
1208
|
-
@if (props().label) {
|
|
1209
|
-
<label class="label" [for]="inputId">{{ props().label }}</label>
|
|
1210
|
-
}
|
|
1211
|
-
<span class="value">{{ props().value }}</span>
|
|
1212
|
-
</div>
|
|
1213
|
-
<input
|
|
1214
|
-
type="range"
|
|
1215
|
-
class="range"
|
|
1216
|
-
[id]="inputId"
|
|
1217
|
-
[min]="props().min ?? 0"
|
|
1218
|
-
[max]="props().max"
|
|
1219
|
-
[value]="props().value ?? 0"
|
|
1220
|
-
(input)="update($event)"
|
|
1221
|
-
/>
|
|
1222
|
-
`, styles: [":host{display:flex;flex-direction:column;gap:calc(var(--a2ui-spacing-m, 8px) / 2);width:100%}.header{display:flex;justify-content:space-between}.label{font-size:var(--a2ui-font-size-s, 14px);font-weight:700}.value{font-size:var(--a2ui-font-size-xs, 12px);color:var(--a2ui-color-muted, #666)}.range{width:100%;cursor:pointer}\n"] }]
|
|
1223
|
-
}] });
|
|
1224
|
-
|
|
1225
|
-
class CopilotA2UITabs extends CopilotA2UIBasicComponent {
|
|
1226
|
-
selectedIndex = signal(0, /* @ts-ignore */
|
|
1227
|
-
...(ngDevMode ? [{ debugName: "selectedIndex" }] : /* istanbul ignore next */ []));
|
|
1228
|
-
tabs = computed(() => this.props().tabs ?? [], /* @ts-ignore */
|
|
1229
|
-
...(ngDevMode ? [{ debugName: "tabs" }] : /* istanbul ignore next */ []));
|
|
1230
|
-
activeTab = computed(() => this.tabs()[this.selectedIndex()] ?? this.tabs()[0], /* @ts-ignore */
|
|
1231
|
-
...(ngDevMode ? [{ debugName: "activeTab" }] : /* istanbul ignore next */ []));
|
|
1232
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UITabs, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1233
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.0", type: CopilotA2UITabs, isStandalone: true, selector: "copilot-a2ui-tabs", usesInheritance: true, ngImport: i0, template: `
|
|
1234
|
-
<div class="tab-list" role="tablist">
|
|
1235
|
-
@for (tab of tabs(); track $index) {
|
|
1236
|
-
<button
|
|
1237
|
-
type="button"
|
|
1238
|
-
role="tab"
|
|
1239
|
-
class="tab"
|
|
1240
|
-
[class.active]="selectedIndex() === $index"
|
|
1241
|
-
[attr.aria-selected]="selectedIndex() === $index"
|
|
1242
|
-
(click)="selectedIndex.set($index)"
|
|
1243
|
-
>
|
|
1244
|
-
{{ tab.title }}
|
|
1245
|
-
</button>
|
|
1246
|
-
}
|
|
1247
|
-
</div>
|
|
1248
|
-
<div class="tab-panel" role="tabpanel">
|
|
1249
|
-
@if (activeTab(); as tab) {
|
|
1250
|
-
<copilot-a2ui-child [child]="tab.child" />
|
|
1251
|
-
}
|
|
1252
|
-
</div>
|
|
1253
|
-
`, isInline: true, styles: [":host{display:flex;flex-direction:column;width:100%}.tab-list{display:flex;margin-bottom:var(--a2ui-spacing-m, 8px);border-bottom:1px solid var(--a2ui-color-border, #ccc)}.tab{padding:var(--a2ui-button-padding, 8px 16px);border:none;background:none;color:inherit;font-weight:400;cursor:pointer}.active{border-bottom:2px solid var(--a2ui-color-primary, var(--a2ui-primary-color, #007bff));color:var(--a2ui-color-primary, var(--a2ui-primary-color, #007bff));font-weight:700}.tab-panel{flex:1}\n"], dependencies: [{ kind: "component", type: CopilotA2UIChild, selector: "copilot-a2ui-child", inputs: ["child"] }] });
|
|
1254
|
-
}
|
|
1255
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UITabs, decorators: [{
|
|
1256
|
-
type: Component,
|
|
1257
|
-
args: [{ selector: "copilot-a2ui-tabs", imports: [CopilotA2UIChild], template: `
|
|
1258
|
-
<div class="tab-list" role="tablist">
|
|
1259
|
-
@for (tab of tabs(); track $index) {
|
|
1260
|
-
<button
|
|
1261
|
-
type="button"
|
|
1262
|
-
role="tab"
|
|
1263
|
-
class="tab"
|
|
1264
|
-
[class.active]="selectedIndex() === $index"
|
|
1265
|
-
[attr.aria-selected]="selectedIndex() === $index"
|
|
1266
|
-
(click)="selectedIndex.set($index)"
|
|
1267
|
-
>
|
|
1268
|
-
{{ tab.title }}
|
|
1269
|
-
</button>
|
|
1270
|
-
}
|
|
1271
|
-
</div>
|
|
1272
|
-
<div class="tab-panel" role="tabpanel">
|
|
1273
|
-
@if (activeTab(); as tab) {
|
|
1274
|
-
<copilot-a2ui-child [child]="tab.child" />
|
|
1275
|
-
}
|
|
1276
|
-
</div>
|
|
1277
|
-
`, styles: [":host{display:flex;flex-direction:column;width:100%}.tab-list{display:flex;margin-bottom:var(--a2ui-spacing-m, 8px);border-bottom:1px solid var(--a2ui-color-border, #ccc)}.tab{padding:var(--a2ui-button-padding, 8px 16px);border:none;background:none;color:inherit;font-weight:400;cursor:pointer}.active{border-bottom:2px solid var(--a2ui-color-primary, var(--a2ui-primary-color, #007bff));color:var(--a2ui-color-primary, var(--a2ui-primary-color, #007bff));font-weight:700}.tab-panel{flex:1}\n"] }]
|
|
1278
|
-
}] });
|
|
1279
|
-
|
|
1280
|
-
class CopilotA2UIText extends CopilotA2UIBasicComponent {
|
|
1281
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UIText, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1282
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.0", type: CopilotA2UIText, isStandalone: true, selector: "copilot-a2ui-text", usesInheritance: true, ngImport: i0, template: `
|
|
1283
|
-
@switch (props().variant) {
|
|
1284
|
-
@case ("h1") {
|
|
1285
|
-
<h1 class="text">{{ props().text }}</h1>
|
|
1286
|
-
}
|
|
1287
|
-
@case ("h2") {
|
|
1288
|
-
<h2 class="text">{{ props().text }}</h2>
|
|
1289
|
-
}
|
|
1290
|
-
@case ("h3") {
|
|
1291
|
-
<h3 class="text">{{ props().text }}</h3>
|
|
1292
|
-
}
|
|
1293
|
-
@case ("h4") {
|
|
1294
|
-
<h4 class="text">{{ props().text }}</h4>
|
|
1295
|
-
}
|
|
1296
|
-
@case ("h5") {
|
|
1297
|
-
<h5 class="text">{{ props().text }}</h5>
|
|
1298
|
-
}
|
|
1299
|
-
@case ("caption") {
|
|
1300
|
-
<small class="text caption">{{ props().text }}</small>
|
|
1301
|
-
}
|
|
1302
|
-
@default {
|
|
1303
|
-
<span class="text">{{ props().text }}</span>
|
|
1304
|
-
}
|
|
1305
|
-
}
|
|
1306
|
-
`, isInline: true, styles: [":host{display:inline-block}.text{display:block;box-sizing:border-box}.caption{color:var(--a2ui-color-muted, #666);text-align:left}\n"] });
|
|
1307
|
-
}
|
|
1308
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UIText, decorators: [{
|
|
1309
|
-
type: Component,
|
|
1310
|
-
args: [{ selector: "copilot-a2ui-text", template: `
|
|
1311
|
-
@switch (props().variant) {
|
|
1312
|
-
@case ("h1") {
|
|
1313
|
-
<h1 class="text">{{ props().text }}</h1>
|
|
1314
|
-
}
|
|
1315
|
-
@case ("h2") {
|
|
1316
|
-
<h2 class="text">{{ props().text }}</h2>
|
|
1317
|
-
}
|
|
1318
|
-
@case ("h3") {
|
|
1319
|
-
<h3 class="text">{{ props().text }}</h3>
|
|
1320
|
-
}
|
|
1321
|
-
@case ("h4") {
|
|
1322
|
-
<h4 class="text">{{ props().text }}</h4>
|
|
1323
|
-
}
|
|
1324
|
-
@case ("h5") {
|
|
1325
|
-
<h5 class="text">{{ props().text }}</h5>
|
|
1326
|
-
}
|
|
1327
|
-
@case ("caption") {
|
|
1328
|
-
<small class="text caption">{{ props().text }}</small>
|
|
1329
|
-
}
|
|
1330
|
-
@default {
|
|
1331
|
-
<span class="text">{{ props().text }}</span>
|
|
1332
|
-
}
|
|
1333
|
-
}
|
|
1334
|
-
`, styles: [":host{display:inline-block}.text{display:block;box-sizing:border-box}.caption{color:var(--a2ui-color-muted, #666);text-align:left}\n"] }]
|
|
1335
|
-
}] });
|
|
1336
|
-
|
|
1337
|
-
class CopilotA2UITextField extends CopilotA2UIBasicComponent {
|
|
1338
|
-
inputId = uniqueId("textfield");
|
|
1339
|
-
error = computed(() => this.props().validationErrors?.[0], /* @ts-ignore */
|
|
1340
|
-
...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
1341
|
-
type = computed(() => {
|
|
1342
|
-
switch (this.props().variant) {
|
|
1343
|
-
case "number":
|
|
1344
|
-
return "number";
|
|
1345
|
-
case "obscured":
|
|
1346
|
-
return "password";
|
|
1347
|
-
default:
|
|
1348
|
-
return "text";
|
|
1349
|
-
}
|
|
1350
|
-
}, /* @ts-ignore */
|
|
1351
|
-
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
1352
|
-
update(event) {
|
|
1353
|
-
this.props().setValue(event.target.value);
|
|
1354
|
-
}
|
|
1355
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UITextField, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1356
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.0", type: CopilotA2UITextField, isStandalone: true, selector: "copilot-a2ui-text-field", usesInheritance: true, ngImport: i0, template: `
|
|
1357
|
-
@if (props().label) {
|
|
1358
|
-
<label class="label" [for]="inputId">{{ props().label }}</label>
|
|
1359
|
-
}
|
|
1360
|
-
@if (props().variant === "longText") {
|
|
1361
|
-
<textarea
|
|
1362
|
-
class="input"
|
|
1363
|
-
[class.invalid]="error()"
|
|
1364
|
-
[id]="inputId"
|
|
1365
|
-
[value]="props().value ?? ''"
|
|
1366
|
-
(input)="update($event)"
|
|
1367
|
-
></textarea>
|
|
1368
|
-
} @else {
|
|
1369
|
-
<input
|
|
1370
|
-
class="input"
|
|
1371
|
-
[class.invalid]="error()"
|
|
1372
|
-
[id]="inputId"
|
|
1373
|
-
[type]="type()"
|
|
1374
|
-
[value]="props().value ?? ''"
|
|
1375
|
-
(input)="update($event)"
|
|
1376
|
-
/>
|
|
1377
|
-
}
|
|
1378
|
-
@if (error(); as error) {
|
|
1379
|
-
<span class="error">{{ error }}</span>
|
|
1380
|
-
}
|
|
1381
|
-
`, isInline: true, styles: [":host{display:flex;flex-direction:column;gap:calc(var(--a2ui-spacing-m, 8px) / 2);width:100%}.label{font-size:var(--a2ui-font-size-s, 14px);font-weight:700}.input{width:100%;padding:var(--a2ui-input-padding, 8px);border:1px solid var(--a2ui-color-border, #ccc);border-radius:var(--a2ui-border-radius, 8px);box-sizing:border-box;background-color:var(--a2ui-color-input, Field);color:var(--a2ui-color-on-input, FieldText)}.invalid{border:1px solid var(--a2ui-color-error, red)}.error{font-size:var(--a2ui-font-size-xs, 12px);color:var(--a2ui-color-error, red)}\n"] });
|
|
1382
|
-
}
|
|
1383
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UITextField, decorators: [{
|
|
1384
|
-
type: Component,
|
|
1385
|
-
args: [{ selector: "copilot-a2ui-text-field", template: `
|
|
1386
|
-
@if (props().label) {
|
|
1387
|
-
<label class="label" [for]="inputId">{{ props().label }}</label>
|
|
1388
|
-
}
|
|
1389
|
-
@if (props().variant === "longText") {
|
|
1390
|
-
<textarea
|
|
1391
|
-
class="input"
|
|
1392
|
-
[class.invalid]="error()"
|
|
1393
|
-
[id]="inputId"
|
|
1394
|
-
[value]="props().value ?? ''"
|
|
1395
|
-
(input)="update($event)"
|
|
1396
|
-
></textarea>
|
|
1397
|
-
} @else {
|
|
1398
|
-
<input
|
|
1399
|
-
class="input"
|
|
1400
|
-
[class.invalid]="error()"
|
|
1401
|
-
[id]="inputId"
|
|
1402
|
-
[type]="type()"
|
|
1403
|
-
[value]="props().value ?? ''"
|
|
1404
|
-
(input)="update($event)"
|
|
1405
|
-
/>
|
|
1406
|
-
}
|
|
1407
|
-
@if (error(); as error) {
|
|
1408
|
-
<span class="error">{{ error }}</span>
|
|
1409
|
-
}
|
|
1410
|
-
`, styles: [":host{display:flex;flex-direction:column;gap:calc(var(--a2ui-spacing-m, 8px) / 2);width:100%}.label{font-size:var(--a2ui-font-size-s, 14px);font-weight:700}.input{width:100%;padding:var(--a2ui-input-padding, 8px);border:1px solid var(--a2ui-color-border, #ccc);border-radius:var(--a2ui-border-radius, 8px);box-sizing:border-box;background-color:var(--a2ui-color-input, Field);color:var(--a2ui-color-on-input, FieldText)}.invalid{border:1px solid var(--a2ui-color-error, red)}.error{font-size:var(--a2ui-font-size-xs, 12px);color:var(--a2ui-color-error, red)}\n"] }]
|
|
1411
|
-
}] });
|
|
1412
|
-
|
|
1413
|
-
class CopilotA2UIVideo extends CopilotA2UIBasicComponent {
|
|
1414
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UIVideo, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1415
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.0", type: CopilotA2UIVideo, isStandalone: true, selector: "copilot-a2ui-video", usesInheritance: true, ngImport: i0, template: `
|
|
1416
|
-
<video class="video" controls [src]="props().url ?? ''"></video>
|
|
1417
|
-
`, isInline: true, styles: [":host{display:block}.video{width:100%;aspect-ratio:16 / 9;box-sizing:border-box}\n"] });
|
|
1418
|
-
}
|
|
1419
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.0", ngImport: i0, type: CopilotA2UIVideo, decorators: [{
|
|
1420
|
-
type: Component,
|
|
1421
|
-
args: [{ selector: "copilot-a2ui-video", template: `
|
|
1422
|
-
<video class="video" controls [src]="props().url ?? ''"></video>
|
|
1423
|
-
`, styles: [":host{display:block}.video{width:100%;aspect-ratio:16 / 9;box-sizing:border-box}\n"] }]
|
|
1424
|
-
}] });
|
|
1425
|
-
|
|
1426
|
-
// Kept here rather than imported from `@copilotkit/angular`: a runtime import
|
|
1427
|
-
// of the main entry pulls all of it into apps that load a catalog eagerly.
|
|
1428
|
-
const A2UI_BASIC_CATALOG_ID = "https://a2ui.org/specification/v0_9/basic_catalog.json";
|
|
1429
|
-
function implement(api, component) {
|
|
1430
|
-
return { name: api.name, schema: api.schema, component };
|
|
1431
|
-
}
|
|
1432
|
-
/** The A2UI basic components. */
|
|
1433
|
-
const basicComponents = [
|
|
1434
|
-
implement(TextApi, CopilotA2UIText),
|
|
1435
|
-
implement(ImageApi, CopilotA2UIImage),
|
|
1436
|
-
implement(IconApi, CopilotA2UIIcon),
|
|
1437
|
-
implement(VideoApi, CopilotA2UIVideo),
|
|
1438
|
-
implement(AudioPlayerApi, CopilotA2UIAudioPlayer),
|
|
1439
|
-
implement(RowApi, CopilotA2UIRow),
|
|
1440
|
-
implement(ColumnApi, CopilotA2UIColumn),
|
|
1441
|
-
implement(ListApi, CopilotA2UIList),
|
|
1442
|
-
implement(CardApi, CopilotA2UICard),
|
|
1443
|
-
implement(TabsApi, CopilotA2UITabs),
|
|
1444
|
-
implement(DividerApi, CopilotA2UIDivider),
|
|
1445
|
-
implement(ModalApi, CopilotA2UIModal),
|
|
1446
|
-
implement(ButtonApi, CopilotA2UIButton),
|
|
1447
|
-
implement(TextFieldApi, CopilotA2UITextField),
|
|
1448
|
-
implement(CheckBoxApi, CopilotA2UICheckBox),
|
|
1449
|
-
implement(ChoicePickerApi, CopilotA2UIChoicePicker),
|
|
1450
|
-
implement(SliderApi, CopilotA2UISlider),
|
|
1451
|
-
implement(DateTimeInputApi, CopilotA2UIDateTimeInput),
|
|
1452
|
-
];
|
|
1453
|
-
/**
|
|
1454
|
-
* The A2UI basic catalog rendered with Angular components. Pass it as
|
|
1455
|
-
* `a2ui.catalog`, or extend it with `createAngularCatalog(..., { includeBasicCatalog: true })`.
|
|
1456
|
-
*/
|
|
1457
|
-
const basicCatalog = new CopilotA2UICatalog(A2UI_BASIC_CATALOG_ID, [...basicComponents], BASIC_FUNCTIONS);
|
|
1458
|
-
|
|
1459
|
-
const DEFAULT_CATALOG_ID = "copilotkit://angular-catalog";
|
|
1460
|
-
/**
|
|
1461
|
-
* Build a {@link CopilotA2UICatalog} from zod definitions and, per entry, an
|
|
1462
|
-
* Angular component or a Custom Element (`{ tagName, element }`).
|
|
1463
|
-
* Without `includeBasicCatalog` the catalog contains exactly what you
|
|
1464
|
-
* register, so include any layout primitives the agent should use.
|
|
1465
|
-
*/
|
|
1466
|
-
function createAngularCatalog(definitions, components, options) {
|
|
1467
|
-
const implementations = Object.entries(definitions).map(([name, definition]) => {
|
|
1468
|
-
const component = components[name];
|
|
1469
|
-
const schema = definition.description
|
|
1470
|
-
? definition.props.describe(definition.description)
|
|
1471
|
-
: definition.props;
|
|
1472
|
-
if (typeof component === "function" && reflectComponentType(component)) {
|
|
1473
|
-
return { name, schema, component };
|
|
1474
|
-
}
|
|
1475
|
-
if (isWebComponentImplementation(component)) {
|
|
1476
|
-
const { tagName, element } = component;
|
|
1477
|
-
return { name, schema, tagName, element };
|
|
1478
|
-
}
|
|
1479
|
-
throw new Error(`A2UI catalog entry "${name}" needs an Angular component or { tagName, element }.`);
|
|
1480
|
-
});
|
|
1481
|
-
return new CopilotA2UICatalog(options?.catalogId ?? DEFAULT_CATALOG_ID, [
|
|
1482
|
-
...(options?.includeBasicCatalog ? basicComponents : []),
|
|
1483
|
-
...implementations,
|
|
1484
|
-
], options?.functions ?? BASIC_FUNCTIONS);
|
|
1485
|
-
}
|
|
1486
|
-
|
|
1487
|
-
/**
|
|
1488
|
-
* Generated bundle index. Do not edit.
|
|
1489
|
-
*/
|
|
1490
|
-
|
|
1491
|
-
export { A2UI_COMPONENT_CONTEXT, CopilotA2UICatalog, CopilotA2UIChild, CopilotA2UISurface, basicCatalog, createAngularCatalog, injectA2UIComponentContext };
|
|
1492
|
-
//# sourceMappingURL=copilotkit-angular-a2ui.mjs.map
|