@a2ui/angular 0.8.1 → 0.8.3
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/fesm2022/a2ui-angular-audio-DoZb9mn_.mjs +48 -0
- package/fesm2022/a2ui-angular-audio-DoZb9mn_.mjs.map +1 -0
- package/fesm2022/a2ui-angular-button-CvH0kAtN.mjs +61 -0
- package/fesm2022/a2ui-angular-button-CvH0kAtN.mjs.map +1 -0
- package/fesm2022/a2ui-angular-card-Ix6OIdUv.mjs +48 -0
- package/fesm2022/a2ui-angular-card-Ix6OIdUv.mjs.map +1 -0
- package/fesm2022/a2ui-angular-checkbox-BN4EF2Ci.mjs +78 -0
- package/fesm2022/a2ui-angular-checkbox-BN4EF2Ci.mjs.map +1 -0
- package/fesm2022/a2ui-angular-datetime-input-dmZAjvrF.mjs +120 -0
- package/fesm2022/a2ui-angular-datetime-input-dmZAjvrF.mjs.map +1 -0
- package/fesm2022/a2ui-angular-divider-BizPl3qL.mjs +30 -0
- package/fesm2022/a2ui-angular-divider-BizPl3qL.mjs.map +1 -0
- package/fesm2022/a2ui-angular-icon-BE9Hj9V6.mjs +48 -0
- package/fesm2022/a2ui-angular-icon-BE9Hj9V6.mjs.map +1 -0
- package/fesm2022/a2ui-angular-image-BWzAw0rh.mjs +54 -0
- package/fesm2022/a2ui-angular-image-BWzAw0rh.mjs.map +1 -0
- package/fesm2022/a2ui-angular-list-nEeT59V3.mjs +45 -0
- package/fesm2022/a2ui-angular-list-nEeT59V3.mjs.map +1 -0
- package/fesm2022/a2ui-angular-modal-mr9LmczA.mjs +108 -0
- package/fesm2022/a2ui-angular-modal-mr9LmczA.mjs.map +1 -0
- package/fesm2022/a2ui-angular-multiple-choice-Bry7X74i.mjs +78 -0
- package/fesm2022/a2ui-angular-multiple-choice-Bry7X74i.mjs.map +1 -0
- package/fesm2022/a2ui-angular-slider-BgseUbN2.mjs +79 -0
- package/fesm2022/a2ui-angular-slider-BgseUbN2.mjs.map +1 -0
- package/fesm2022/a2ui-angular-tabs-q5Mn9vgq.mjs +87 -0
- package/fesm2022/a2ui-angular-tabs-q5Mn9vgq.mjs.map +1 -0
- package/fesm2022/a2ui-angular-text-field-Deokh07j.mjs +85 -0
- package/fesm2022/a2ui-angular-text-field-Deokh07j.mjs.map +1 -0
- package/fesm2022/a2ui-angular-video-DuFTfN0B.mjs +48 -0
- package/fesm2022/a2ui-angular-video-DuFTfN0B.mjs.map +1 -0
- package/fesm2022/a2ui-angular.mjs +872 -0
- package/fesm2022/a2ui-angular.mjs.map +1 -0
- package/package.json +13 -46
- package/types/a2ui-angular.d.ts +90 -0
- package/angular.json +0 -35
- package/ng-package.json +0 -8
- package/src/lib/catalog/audio.ts +0 -50
- package/src/lib/catalog/button.ts +0 -56
- package/src/lib/catalog/card.ts +0 -57
- package/src/lib/catalog/checkbox.ts +0 -73
- package/src/lib/catalog/column.ts +0 -96
- package/src/lib/catalog/datetime-input.ts +0 -127
- package/src/lib/catalog/default.ts +0 -185
- package/src/lib/catalog/divider.ts +0 -37
- package/src/lib/catalog/icon.ts +0 -44
- package/src/lib/catalog/image.ts +0 -62
- package/src/lib/catalog/list.ts +0 -63
- package/src/lib/catalog/modal.ts +0 -113
- package/src/lib/catalog/multiple-choice.ts +0 -77
- package/src/lib/catalog/row.ts +0 -100
- package/src/lib/catalog/slider.ts +0 -73
- package/src/lib/catalog/surface.ts +0 -82
- package/src/lib/catalog/tabs.ts +0 -72
- package/src/lib/catalog/text-field.ts +0 -86
- package/src/lib/catalog/text.ts +0 -137
- package/src/lib/catalog/video.ts +0 -50
- package/src/lib/config.ts +0 -25
- package/src/lib/data/index.ts +0 -18
- package/src/lib/data/markdown.ts +0 -114
- package/src/lib/data/processor.ts +0 -47
- package/src/lib/data/types.ts +0 -29
- package/src/lib/rendering/catalog.ts +0 -36
- package/src/lib/rendering/dynamic-component.ts +0 -100
- package/src/lib/rendering/index.ts +0 -20
- package/src/lib/rendering/renderer.ts +0 -109
- package/src/lib/rendering/theming.ts +0 -22
- package/src/public-api.ts +0 -21
- package/tsconfig.json +0 -23
- package/tsconfig.lib.json +0 -16
- package/tsconfig.lib.prod.json +0 -9
- package/tsconfig.spec.json +0 -12
|
@@ -0,0 +1,872 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, Injectable, inject, input, Directive, ViewContainerRef, effect, untracked, PLATFORM_ID, DOCUMENT, inputBinding, makeEnvironmentProviders, computed, Component, SecurityContext, ViewEncapsulation } from '@angular/core';
|
|
3
|
+
import { Data, Styles } from '@a2ui/lit/0.8';
|
|
4
|
+
import { Subject, firstValueFrom } from 'rxjs';
|
|
5
|
+
import { isPlatformBrowser } from '@angular/common';
|
|
6
|
+
import { DomSanitizer } from '@angular/platform-browser';
|
|
7
|
+
import MarkdownIt from 'markdown-it';
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
Copyright 2025 Google LLC
|
|
11
|
+
|
|
12
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
you may not use this file except in compliance with the License.
|
|
14
|
+
You may obtain a copy of the License at
|
|
15
|
+
|
|
16
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
+
|
|
18
|
+
Unless required by applicable law or agreed to in writing, software
|
|
19
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
+
See the License for the specific language governing permissions and
|
|
22
|
+
limitations under the License.
|
|
23
|
+
*/
|
|
24
|
+
const Catalog = new InjectionToken('Catalog');
|
|
25
|
+
|
|
26
|
+
/*
|
|
27
|
+
Copyright 2025 Google LLC
|
|
28
|
+
|
|
29
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
30
|
+
you may not use this file except in compliance with the License.
|
|
31
|
+
You may obtain a copy of the License at
|
|
32
|
+
|
|
33
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
34
|
+
|
|
35
|
+
Unless required by applicable law or agreed to in writing, software
|
|
36
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
37
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
38
|
+
See the License for the specific language governing permissions and
|
|
39
|
+
limitations under the License.
|
|
40
|
+
*/
|
|
41
|
+
class MessageProcessor extends Data.A2uiMessageProcessor {
|
|
42
|
+
events = new Subject();
|
|
43
|
+
setData(node, relativePath, value, surfaceId) {
|
|
44
|
+
// Override setData to convert from optional inputs (which can be null)
|
|
45
|
+
// to undefined so that this correctly falls back to the default value for
|
|
46
|
+
// surfaceId.
|
|
47
|
+
return super.setData(node, relativePath, value, surfaceId ?? undefined);
|
|
48
|
+
}
|
|
49
|
+
dispatch(message) {
|
|
50
|
+
const completion = new Subject();
|
|
51
|
+
this.events.next({ message, completion });
|
|
52
|
+
return firstValueFrom(completion);
|
|
53
|
+
}
|
|
54
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: MessageProcessor, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
55
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: MessageProcessor, providedIn: 'root' });
|
|
56
|
+
}
|
|
57
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: MessageProcessor, decorators: [{
|
|
58
|
+
type: Injectable,
|
|
59
|
+
args: [{ providedIn: 'root' }]
|
|
60
|
+
}] });
|
|
61
|
+
|
|
62
|
+
/*
|
|
63
|
+
Copyright 2025 Google LLC
|
|
64
|
+
|
|
65
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
66
|
+
you may not use this file except in compliance with the License.
|
|
67
|
+
You may obtain a copy of the License at
|
|
68
|
+
|
|
69
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
70
|
+
|
|
71
|
+
Unless required by applicable law or agreed to in writing, software
|
|
72
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
73
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
74
|
+
See the License for the specific language governing permissions and
|
|
75
|
+
limitations under the License.
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
/*
|
|
79
|
+
Copyright 2025 Google LLC
|
|
80
|
+
|
|
81
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
82
|
+
you may not use this file except in compliance with the License.
|
|
83
|
+
You may obtain a copy of the License at
|
|
84
|
+
|
|
85
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
86
|
+
|
|
87
|
+
Unless required by applicable law or agreed to in writing, software
|
|
88
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
89
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
90
|
+
See the License for the specific language governing permissions and
|
|
91
|
+
limitations under the License.
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
/*
|
|
95
|
+
Copyright 2025 Google LLC
|
|
96
|
+
|
|
97
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
98
|
+
you may not use this file except in compliance with the License.
|
|
99
|
+
You may obtain a copy of the License at
|
|
100
|
+
|
|
101
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
102
|
+
|
|
103
|
+
Unless required by applicable law or agreed to in writing, software
|
|
104
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
105
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
106
|
+
See the License for the specific language governing permissions and
|
|
107
|
+
limitations under the License.
|
|
108
|
+
*/
|
|
109
|
+
const Theme = new InjectionToken('Theme');
|
|
110
|
+
|
|
111
|
+
let idCounter = 0;
|
|
112
|
+
class DynamicComponent {
|
|
113
|
+
processor = inject(MessageProcessor);
|
|
114
|
+
theme = inject(Theme);
|
|
115
|
+
surfaceId = input.required(...(ngDevMode ? [{ debugName: "surfaceId" }] : []));
|
|
116
|
+
component = input.required(...(ngDevMode ? [{ debugName: "component" }] : []));
|
|
117
|
+
weight = input.required(...(ngDevMode ? [{ debugName: "weight" }] : []));
|
|
118
|
+
sendAction(action) {
|
|
119
|
+
const component = this.component();
|
|
120
|
+
const surfaceId = this.surfaceId() ?? undefined;
|
|
121
|
+
const context = {};
|
|
122
|
+
if (action.context) {
|
|
123
|
+
for (const item of action.context) {
|
|
124
|
+
if (item.value.literalBoolean) {
|
|
125
|
+
context[item.key] = item.value.literalBoolean;
|
|
126
|
+
}
|
|
127
|
+
else if (item.value.literalNumber) {
|
|
128
|
+
context[item.key] = item.value.literalNumber;
|
|
129
|
+
}
|
|
130
|
+
else if (item.value.literalString) {
|
|
131
|
+
context[item.key] = item.value.literalString;
|
|
132
|
+
}
|
|
133
|
+
else if (item.value.path) {
|
|
134
|
+
const path = this.processor.resolvePath(item.value.path, component.dataContextPath);
|
|
135
|
+
const value = this.processor.getData(component, path, surfaceId);
|
|
136
|
+
context[item.key] = value;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const message = {
|
|
141
|
+
userAction: {
|
|
142
|
+
name: action.name,
|
|
143
|
+
sourceComponentId: component.id,
|
|
144
|
+
surfaceId: surfaceId,
|
|
145
|
+
timestamp: new Date().toISOString(),
|
|
146
|
+
context,
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
return this.processor.dispatch(message);
|
|
150
|
+
}
|
|
151
|
+
resolvePrimitive(value) {
|
|
152
|
+
const component = this.component();
|
|
153
|
+
const surfaceId = this.surfaceId();
|
|
154
|
+
if (!value || typeof value !== 'object') {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
else if (value.literal != null) {
|
|
158
|
+
return value.literal;
|
|
159
|
+
}
|
|
160
|
+
else if (value.path) {
|
|
161
|
+
return this.processor.getData(component, value.path, surfaceId ?? undefined);
|
|
162
|
+
}
|
|
163
|
+
else if ('literalString' in value) {
|
|
164
|
+
return value.literalString;
|
|
165
|
+
}
|
|
166
|
+
else if ('literalNumber' in value) {
|
|
167
|
+
return value.literalNumber;
|
|
168
|
+
}
|
|
169
|
+
else if ('literalBoolean' in value) {
|
|
170
|
+
return value.literalBoolean;
|
|
171
|
+
}
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
getUniqueId(prefix) {
|
|
175
|
+
return `${prefix}-${idCounter++}`;
|
|
176
|
+
}
|
|
177
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: DynamicComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
178
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.0.3", type: DynamicComponent, isStandalone: true, inputs: { surfaceId: { classPropertyName: "surfaceId", publicName: "surfaceId", isSignal: true, isRequired: true, transformFunction: null }, component: { classPropertyName: "component", publicName: "component", isSignal: true, isRequired: true, transformFunction: null }, weight: { classPropertyName: "weight", publicName: "weight", isSignal: true, isRequired: true, transformFunction: null } }, host: { properties: { "style.--weight": "weight()" } }, ngImport: i0 });
|
|
179
|
+
}
|
|
180
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: DynamicComponent, decorators: [{
|
|
181
|
+
type: Directive,
|
|
182
|
+
args: [{
|
|
183
|
+
host: {
|
|
184
|
+
'[style.--weight]': 'weight()',
|
|
185
|
+
},
|
|
186
|
+
}]
|
|
187
|
+
}], propDecorators: { surfaceId: [{ type: i0.Input, args: [{ isSignal: true, alias: "surfaceId", required: true }] }], component: [{ type: i0.Input, args: [{ isSignal: true, alias: "component", required: true }] }], weight: [{ type: i0.Input, args: [{ isSignal: true, alias: "weight", required: true }] }] } });
|
|
188
|
+
|
|
189
|
+
/*
|
|
190
|
+
Copyright 2025 Google LLC
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
203
|
+
*/
|
|
204
|
+
class Renderer {
|
|
205
|
+
viewContainerRef = inject(ViewContainerRef);
|
|
206
|
+
catalog = inject(Catalog);
|
|
207
|
+
static hasInsertedStyles = false;
|
|
208
|
+
currentRef = null;
|
|
209
|
+
isDestroyed = false;
|
|
210
|
+
surfaceId = input.required(...(ngDevMode ? [{ debugName: "surfaceId" }] : []));
|
|
211
|
+
component = input.required(...(ngDevMode ? [{ debugName: "component" }] : []));
|
|
212
|
+
constructor() {
|
|
213
|
+
effect(() => {
|
|
214
|
+
const surfaceId = this.surfaceId();
|
|
215
|
+
const component = this.component();
|
|
216
|
+
untracked(() => this.render(surfaceId, component));
|
|
217
|
+
});
|
|
218
|
+
const platformId = inject(PLATFORM_ID);
|
|
219
|
+
const document = inject(DOCUMENT);
|
|
220
|
+
if (!Renderer.hasInsertedStyles && isPlatformBrowser(platformId)) {
|
|
221
|
+
const styles = document.createElement('style');
|
|
222
|
+
styles.textContent = Styles.structuralStyles;
|
|
223
|
+
document.head.appendChild(styles);
|
|
224
|
+
Renderer.hasInsertedStyles = true;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
ngOnDestroy() {
|
|
228
|
+
this.isDestroyed = true;
|
|
229
|
+
this.clear();
|
|
230
|
+
}
|
|
231
|
+
async render(surfaceId, component) {
|
|
232
|
+
const config = this.catalog[component.type];
|
|
233
|
+
let newComponent = null;
|
|
234
|
+
let componentBindings = null;
|
|
235
|
+
if (typeof config === 'function') {
|
|
236
|
+
newComponent = await config();
|
|
237
|
+
}
|
|
238
|
+
else if (typeof config === 'object') {
|
|
239
|
+
newComponent = await config.type();
|
|
240
|
+
componentBindings = config.bindings(component);
|
|
241
|
+
}
|
|
242
|
+
this.clear();
|
|
243
|
+
if (newComponent && !this.isDestroyed) {
|
|
244
|
+
const bindings = [
|
|
245
|
+
inputBinding('surfaceId', () => surfaceId),
|
|
246
|
+
inputBinding('component', () => component),
|
|
247
|
+
inputBinding('weight', () => component.weight ?? 'initial'),
|
|
248
|
+
];
|
|
249
|
+
if (componentBindings) {
|
|
250
|
+
bindings.push(...componentBindings);
|
|
251
|
+
}
|
|
252
|
+
this.currentRef = this.viewContainerRef.createComponent(newComponent, {
|
|
253
|
+
bindings,
|
|
254
|
+
injector: this.viewContainerRef.injector,
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
clear() {
|
|
259
|
+
this.currentRef?.destroy();
|
|
260
|
+
this.currentRef = null;
|
|
261
|
+
}
|
|
262
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: Renderer, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
263
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.0.3", type: Renderer, isStandalone: true, selector: "ng-container[a2ui-renderer]", inputs: { surfaceId: { classPropertyName: "surfaceId", publicName: "surfaceId", isSignal: true, isRequired: true, transformFunction: null }, component: { classPropertyName: "component", publicName: "component", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0 });
|
|
264
|
+
}
|
|
265
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: Renderer, decorators: [{
|
|
266
|
+
type: Directive,
|
|
267
|
+
args: [{
|
|
268
|
+
selector: 'ng-container[a2ui-renderer]',
|
|
269
|
+
}]
|
|
270
|
+
}], ctorParameters: () => [], propDecorators: { surfaceId: [{ type: i0.Input, args: [{ isSignal: true, alias: "surfaceId", required: true }] }], component: [{ type: i0.Input, args: [{ isSignal: true, alias: "component", required: true }] }] } });
|
|
271
|
+
|
|
272
|
+
/*
|
|
273
|
+
Copyright 2025 Google LLC
|
|
274
|
+
|
|
275
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
276
|
+
you may not use this file except in compliance with the License.
|
|
277
|
+
You may obtain a copy of the License at
|
|
278
|
+
|
|
279
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
280
|
+
|
|
281
|
+
Unless required by applicable law or agreed to in writing, software
|
|
282
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
283
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
284
|
+
See the License for the specific language governing permissions and
|
|
285
|
+
limitations under the License.
|
|
286
|
+
*/
|
|
287
|
+
|
|
288
|
+
/*
|
|
289
|
+
Copyright 2025 Google LLC
|
|
290
|
+
|
|
291
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
292
|
+
you may not use this file except in compliance with the License.
|
|
293
|
+
You may obtain a copy of the License at
|
|
294
|
+
|
|
295
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
296
|
+
|
|
297
|
+
Unless required by applicable law or agreed to in writing, software
|
|
298
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
299
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
300
|
+
See the License for the specific language governing permissions and
|
|
301
|
+
limitations under the License.
|
|
302
|
+
*/
|
|
303
|
+
function provideA2UI(config) {
|
|
304
|
+
return makeEnvironmentProviders([
|
|
305
|
+
{ provide: Catalog, useValue: config.catalog },
|
|
306
|
+
{ provide: Theme, useValue: config.theme },
|
|
307
|
+
]);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/*
|
|
311
|
+
Copyright 2025 Google LLC
|
|
312
|
+
|
|
313
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
314
|
+
you may not use this file except in compliance with the License.
|
|
315
|
+
You may obtain a copy of the License at
|
|
316
|
+
|
|
317
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
318
|
+
|
|
319
|
+
Unless required by applicable law or agreed to in writing, software
|
|
320
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
321
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
322
|
+
See the License for the specific language governing permissions and
|
|
323
|
+
limitations under the License.
|
|
324
|
+
*/
|
|
325
|
+
class Row extends DynamicComponent {
|
|
326
|
+
alignment = input('stretch', ...(ngDevMode ? [{ debugName: "alignment" }] : []));
|
|
327
|
+
distribution = input('start', ...(ngDevMode ? [{ debugName: "distribution" }] : []));
|
|
328
|
+
classes = computed(() => ({
|
|
329
|
+
...this.theme.components.Row,
|
|
330
|
+
[`align-${this.alignment()}`]: true,
|
|
331
|
+
[`distribute-${this.distribution()}`]: true,
|
|
332
|
+
}), ...(ngDevMode ? [{ debugName: "classes" }] : []));
|
|
333
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: Row, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
334
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.3", type: Row, isStandalone: true, selector: "a2ui-row", inputs: { alignment: { classPropertyName: "alignment", publicName: "alignment", isSignal: true, isRequired: false, transformFunction: null }, distribution: { classPropertyName: "distribution", publicName: "distribution", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.alignment": "alignment()", "attr.distribution": "distribution()" } }, usesInheritance: true, ngImport: i0, template: `
|
|
335
|
+
<section [class]="classes()" [style]="theme.additionalStyles?.Row">
|
|
336
|
+
@for (child of component().properties.children; track child) {
|
|
337
|
+
<ng-container a2ui-renderer [surfaceId]="surfaceId()!" [component]="child" />
|
|
338
|
+
}
|
|
339
|
+
</section>
|
|
340
|
+
`, isInline: true, styles: [":host{display:flex;flex:var(--weight)}section{display:flex;flex-direction:row;width:100%;min-height:100%;box-sizing:border-box}.align-start{align-items:start}.align-center{align-items:center}.align-end{align-items:end}.align-stretch{align-items:stretch}.distribute-start{justify-content:start}.distribute-center{justify-content:center}.distribute-end{justify-content:end}.distribute-spaceBetween{justify-content:space-between}.distribute-spaceAround{justify-content:space-around}.distribute-spaceEvenly{justify-content:space-evenly}\n"], dependencies: [{ kind: "directive", type: Renderer, selector: "ng-container[a2ui-renderer]", inputs: ["surfaceId", "component"] }] });
|
|
341
|
+
}
|
|
342
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: Row, decorators: [{
|
|
343
|
+
type: Component,
|
|
344
|
+
args: [{ selector: 'a2ui-row', imports: [Renderer], host: {
|
|
345
|
+
'[attr.alignment]': 'alignment()',
|
|
346
|
+
'[attr.distribution]': 'distribution()',
|
|
347
|
+
}, template: `
|
|
348
|
+
<section [class]="classes()" [style]="theme.additionalStyles?.Row">
|
|
349
|
+
@for (child of component().properties.children; track child) {
|
|
350
|
+
<ng-container a2ui-renderer [surfaceId]="surfaceId()!" [component]="child" />
|
|
351
|
+
}
|
|
352
|
+
</section>
|
|
353
|
+
`, styles: [":host{display:flex;flex:var(--weight)}section{display:flex;flex-direction:row;width:100%;min-height:100%;box-sizing:border-box}.align-start{align-items:start}.align-center{align-items:center}.align-end{align-items:end}.align-stretch{align-items:stretch}.distribute-start{justify-content:start}.distribute-center{justify-content:center}.distribute-end{justify-content:end}.distribute-spaceBetween{justify-content:space-between}.distribute-spaceAround{justify-content:space-around}.distribute-spaceEvenly{justify-content:space-evenly}\n"] }]
|
|
354
|
+
}], propDecorators: { alignment: [{ type: i0.Input, args: [{ isSignal: true, alias: "alignment", required: false }] }], distribution: [{ type: i0.Input, args: [{ isSignal: true, alias: "distribution", required: false }] }] } });
|
|
355
|
+
|
|
356
|
+
/*
|
|
357
|
+
Copyright 2025 Google LLC
|
|
358
|
+
|
|
359
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
360
|
+
you may not use this file except in compliance with the License.
|
|
361
|
+
You may obtain a copy of the License at
|
|
362
|
+
|
|
363
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
364
|
+
|
|
365
|
+
Unless required by applicable law or agreed to in writing, software
|
|
366
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
367
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
368
|
+
See the License for the specific language governing permissions and
|
|
369
|
+
limitations under the License.
|
|
370
|
+
*/
|
|
371
|
+
class Column extends DynamicComponent {
|
|
372
|
+
alignment = input('stretch', ...(ngDevMode ? [{ debugName: "alignment" }] : []));
|
|
373
|
+
distribution = input('start', ...(ngDevMode ? [{ debugName: "distribution" }] : []));
|
|
374
|
+
classes = computed(() => ({
|
|
375
|
+
...this.theme.components.Column,
|
|
376
|
+
[`align-${this.alignment()}`]: true,
|
|
377
|
+
[`distribute-${this.distribution()}`]: true,
|
|
378
|
+
}), ...(ngDevMode ? [{ debugName: "classes" }] : []));
|
|
379
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: Column, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
380
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.3", type: Column, isStandalone: true, selector: "a2ui-column", inputs: { alignment: { classPropertyName: "alignment", publicName: "alignment", isSignal: true, isRequired: false, transformFunction: null }, distribution: { classPropertyName: "distribution", publicName: "distribution", isSignal: true, isRequired: false, transformFunction: null } }, usesInheritance: true, ngImport: i0, template: `
|
|
381
|
+
<section [class]="classes()" [style]="theme.additionalStyles?.Column">
|
|
382
|
+
@for (child of component().properties.children; track child) {
|
|
383
|
+
<ng-container a2ui-renderer [surfaceId]="surfaceId()!" [component]="child" />
|
|
384
|
+
}
|
|
385
|
+
</section>
|
|
386
|
+
`, isInline: true, styles: [":host{display:flex;flex:var(--weight)}section{display:flex;flex-direction:column;min-width:100%;height:100%;box-sizing:border-box}.align-start{align-items:start}.align-center{align-items:center}.align-end{align-items:end}.align-stretch{align-items:stretch}.distribute-start{justify-content:start}.distribute-center{justify-content:center}.distribute-end{justify-content:end}.distribute-spaceBetween{justify-content:space-between}.distribute-spaceAround{justify-content:space-around}.distribute-spaceEvenly{justify-content:space-evenly}\n"], dependencies: [{ kind: "directive", type: Renderer, selector: "ng-container[a2ui-renderer]", inputs: ["surfaceId", "component"] }] });
|
|
387
|
+
}
|
|
388
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: Column, decorators: [{
|
|
389
|
+
type: Component,
|
|
390
|
+
args: [{ selector: 'a2ui-column', imports: [Renderer], template: `
|
|
391
|
+
<section [class]="classes()" [style]="theme.additionalStyles?.Column">
|
|
392
|
+
@for (child of component().properties.children; track child) {
|
|
393
|
+
<ng-container a2ui-renderer [surfaceId]="surfaceId()!" [component]="child" />
|
|
394
|
+
}
|
|
395
|
+
</section>
|
|
396
|
+
`, styles: [":host{display:flex;flex:var(--weight)}section{display:flex;flex-direction:column;min-width:100%;height:100%;box-sizing:border-box}.align-start{align-items:start}.align-center{align-items:center}.align-end{align-items:end}.align-stretch{align-items:stretch}.distribute-start{justify-content:start}.distribute-center{justify-content:center}.distribute-end{justify-content:end}.distribute-spaceBetween{justify-content:space-between}.distribute-spaceAround{justify-content:space-around}.distribute-spaceEvenly{justify-content:space-evenly}\n"] }]
|
|
397
|
+
}], propDecorators: { alignment: [{ type: i0.Input, args: [{ isSignal: true, alias: "alignment", required: false }] }], distribution: [{ type: i0.Input, args: [{ isSignal: true, alias: "distribution", required: false }] }] } });
|
|
398
|
+
|
|
399
|
+
/*
|
|
400
|
+
Copyright 2025 Google LLC
|
|
401
|
+
|
|
402
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
403
|
+
you may not use this file except in compliance with the License.
|
|
404
|
+
You may obtain a copy of the License at
|
|
405
|
+
|
|
406
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
407
|
+
|
|
408
|
+
Unless required by applicable law or agreed to in writing, software
|
|
409
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
410
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
411
|
+
See the License for the specific language governing permissions and
|
|
412
|
+
limitations under the License.
|
|
413
|
+
*/
|
|
414
|
+
class MarkdownRenderer {
|
|
415
|
+
originalClassMap = new Map();
|
|
416
|
+
sanitizer = inject(DomSanitizer);
|
|
417
|
+
markdownIt = MarkdownIt({
|
|
418
|
+
highlight: (str, lang) => {
|
|
419
|
+
if (lang === 'html') {
|
|
420
|
+
const iframe = document.createElement('iframe');
|
|
421
|
+
iframe.classList.add('html-view');
|
|
422
|
+
iframe.srcdoc = str;
|
|
423
|
+
iframe.sandbox = '';
|
|
424
|
+
return iframe.innerHTML;
|
|
425
|
+
}
|
|
426
|
+
return str;
|
|
427
|
+
},
|
|
428
|
+
});
|
|
429
|
+
render(value, tagClassMap) {
|
|
430
|
+
if (tagClassMap) {
|
|
431
|
+
this.applyTagClassMap(tagClassMap);
|
|
432
|
+
}
|
|
433
|
+
const htmlString = this.markdownIt.render(value);
|
|
434
|
+
this.unapplyTagClassMap();
|
|
435
|
+
return this.sanitizer.sanitize(SecurityContext.HTML, htmlString);
|
|
436
|
+
}
|
|
437
|
+
applyTagClassMap(tagClassMap) {
|
|
438
|
+
Object.entries(tagClassMap).forEach(([tag, classes]) => {
|
|
439
|
+
let tokenName;
|
|
440
|
+
switch (tag) {
|
|
441
|
+
case 'p':
|
|
442
|
+
tokenName = 'paragraph';
|
|
443
|
+
break;
|
|
444
|
+
case 'h1':
|
|
445
|
+
case 'h2':
|
|
446
|
+
case 'h3':
|
|
447
|
+
case 'h4':
|
|
448
|
+
case 'h5':
|
|
449
|
+
case 'h6':
|
|
450
|
+
tokenName = 'heading';
|
|
451
|
+
break;
|
|
452
|
+
case 'ul':
|
|
453
|
+
tokenName = 'bullet_list';
|
|
454
|
+
break;
|
|
455
|
+
case 'ol':
|
|
456
|
+
tokenName = 'ordered_list';
|
|
457
|
+
break;
|
|
458
|
+
case 'li':
|
|
459
|
+
tokenName = 'list_item';
|
|
460
|
+
break;
|
|
461
|
+
case 'a':
|
|
462
|
+
tokenName = 'link';
|
|
463
|
+
break;
|
|
464
|
+
case 'strong':
|
|
465
|
+
tokenName = 'strong';
|
|
466
|
+
break;
|
|
467
|
+
case 'em':
|
|
468
|
+
tokenName = 'em';
|
|
469
|
+
break;
|
|
470
|
+
}
|
|
471
|
+
if (!tokenName) {
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
const key = `${tokenName}_open`;
|
|
475
|
+
const original = this.markdownIt.renderer.rules[key];
|
|
476
|
+
this.originalClassMap.set(key, original);
|
|
477
|
+
this.markdownIt.renderer.rules[key] = (tokens, idx, options, env, self) => {
|
|
478
|
+
const token = tokens[idx];
|
|
479
|
+
for (const clazz of classes) {
|
|
480
|
+
token.attrJoin('class', clazz);
|
|
481
|
+
}
|
|
482
|
+
if (original) {
|
|
483
|
+
return original.call(this, tokens, idx, options, env, self);
|
|
484
|
+
}
|
|
485
|
+
else {
|
|
486
|
+
return self.renderToken(tokens, idx, options);
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
unapplyTagClassMap() {
|
|
492
|
+
for (const [key, original] of this.originalClassMap) {
|
|
493
|
+
this.markdownIt.renderer.rules[key] = original;
|
|
494
|
+
}
|
|
495
|
+
this.originalClassMap.clear();
|
|
496
|
+
}
|
|
497
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: MarkdownRenderer, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
498
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: MarkdownRenderer, providedIn: 'root' });
|
|
499
|
+
}
|
|
500
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: MarkdownRenderer, decorators: [{
|
|
501
|
+
type: Injectable,
|
|
502
|
+
args: [{ providedIn: 'root' }]
|
|
503
|
+
}] });
|
|
504
|
+
|
|
505
|
+
/*
|
|
506
|
+
Copyright 2025 Google LLC
|
|
507
|
+
|
|
508
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
509
|
+
you may not use this file except in compliance with the License.
|
|
510
|
+
You may obtain a copy of the License at
|
|
511
|
+
|
|
512
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
513
|
+
|
|
514
|
+
Unless required by applicable law or agreed to in writing, software
|
|
515
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
516
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
517
|
+
See the License for the specific language governing permissions and
|
|
518
|
+
limitations under the License.
|
|
519
|
+
*/
|
|
520
|
+
class Text extends DynamicComponent {
|
|
521
|
+
markdownRenderer = inject(MarkdownRenderer);
|
|
522
|
+
text = input.required(...(ngDevMode ? [{ debugName: "text" }] : []));
|
|
523
|
+
usageHint = input.required(...(ngDevMode ? [{ debugName: "usageHint" }] : []));
|
|
524
|
+
resolvedText = computed(() => {
|
|
525
|
+
const usageHint = this.usageHint();
|
|
526
|
+
let value = super.resolvePrimitive(this.text());
|
|
527
|
+
if (value == null) {
|
|
528
|
+
return '(empty)';
|
|
529
|
+
}
|
|
530
|
+
switch (usageHint) {
|
|
531
|
+
case 'h1':
|
|
532
|
+
value = `# ${value}`;
|
|
533
|
+
break;
|
|
534
|
+
case 'h2':
|
|
535
|
+
value = `## ${value}`;
|
|
536
|
+
break;
|
|
537
|
+
case 'h3':
|
|
538
|
+
value = `### ${value}`;
|
|
539
|
+
break;
|
|
540
|
+
case 'h4':
|
|
541
|
+
value = `#### ${value}`;
|
|
542
|
+
break;
|
|
543
|
+
case 'h5':
|
|
544
|
+
value = `##### ${value}`;
|
|
545
|
+
break;
|
|
546
|
+
case 'caption':
|
|
547
|
+
value = `*${value}*`;
|
|
548
|
+
break;
|
|
549
|
+
default:
|
|
550
|
+
value = String(value);
|
|
551
|
+
break;
|
|
552
|
+
}
|
|
553
|
+
return this.markdownRenderer.render(value, Styles.appendToAll(this.theme.markdown, ['ol', 'ul', 'li'], {}));
|
|
554
|
+
}, ...(ngDevMode ? [{ debugName: "resolvedText" }] : []));
|
|
555
|
+
classes = computed(() => {
|
|
556
|
+
const usageHint = this.usageHint();
|
|
557
|
+
return Styles.merge(this.theme.components.Text.all, usageHint ? this.theme.components.Text[usageHint] : {});
|
|
558
|
+
}, ...(ngDevMode ? [{ debugName: "classes" }] : []));
|
|
559
|
+
additionalStyles = computed(() => {
|
|
560
|
+
const usageHint = this.usageHint();
|
|
561
|
+
const styles = this.theme.additionalStyles?.Text;
|
|
562
|
+
if (!styles) {
|
|
563
|
+
return null;
|
|
564
|
+
}
|
|
565
|
+
let additionalStyles = {};
|
|
566
|
+
if (this.areHintedStyles(styles)) {
|
|
567
|
+
additionalStyles = styles[usageHint ?? 'body'];
|
|
568
|
+
}
|
|
569
|
+
else {
|
|
570
|
+
additionalStyles = styles;
|
|
571
|
+
}
|
|
572
|
+
return additionalStyles;
|
|
573
|
+
}, ...(ngDevMode ? [{ debugName: "additionalStyles" }] : []));
|
|
574
|
+
areHintedStyles(styles) {
|
|
575
|
+
if (typeof styles !== 'object' || !styles || Array.isArray(styles)) {
|
|
576
|
+
return false;
|
|
577
|
+
}
|
|
578
|
+
const expected = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'caption', 'body'];
|
|
579
|
+
return expected.every((v) => v in styles);
|
|
580
|
+
}
|
|
581
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: Text, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
582
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.0.3", type: Text, isStandalone: true, selector: "a2ui-text", inputs: { text: { classPropertyName: "text", publicName: "text", isSignal: true, isRequired: true, transformFunction: null }, usageHint: { classPropertyName: "usageHint", publicName: "usageHint", isSignal: true, isRequired: true, transformFunction: null } }, usesInheritance: true, ngImport: i0, template: `
|
|
583
|
+
<section
|
|
584
|
+
[class]="classes()"
|
|
585
|
+
[style]="additionalStyles()"
|
|
586
|
+
[innerHTML]="resolvedText()"
|
|
587
|
+
></section>
|
|
588
|
+
`, isInline: true, styles: ["a2ui-text{display:block;flex:var(--weight)}a2ui-text h1,a2ui-text h2,a2ui-text h3,a2ui-text h4,a2ui-text h5{line-height:inherit;font:inherit}\n"], encapsulation: i0.ViewEncapsulation.None });
|
|
589
|
+
}
|
|
590
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: Text, decorators: [{
|
|
591
|
+
type: Component,
|
|
592
|
+
args: [{ selector: 'a2ui-text', template: `
|
|
593
|
+
<section
|
|
594
|
+
[class]="classes()"
|
|
595
|
+
[style]="additionalStyles()"
|
|
596
|
+
[innerHTML]="resolvedText()"
|
|
597
|
+
></section>
|
|
598
|
+
`, encapsulation: ViewEncapsulation.None, styles: ["a2ui-text{display:block;flex:var(--weight)}a2ui-text h1,a2ui-text h2,a2ui-text h3,a2ui-text h4,a2ui-text h5{line-height:inherit;font:inherit}\n"] }]
|
|
599
|
+
}], propDecorators: { text: [{ type: i0.Input, args: [{ isSignal: true, alias: "text", required: true }] }], usageHint: [{ type: i0.Input, args: [{ isSignal: true, alias: "usageHint", required: true }] }] } });
|
|
600
|
+
|
|
601
|
+
/*
|
|
602
|
+
Copyright 2025 Google LLC
|
|
603
|
+
|
|
604
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
605
|
+
you may not use this file except in compliance with the License.
|
|
606
|
+
You may obtain a copy of the License at
|
|
607
|
+
|
|
608
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
609
|
+
|
|
610
|
+
Unless required by applicable law or agreed to in writing, software
|
|
611
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
612
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
613
|
+
See the License for the specific language governing permissions and
|
|
614
|
+
limitations under the License.
|
|
615
|
+
*/
|
|
616
|
+
const DEFAULT_CATALOG = {
|
|
617
|
+
Row: {
|
|
618
|
+
type: () => Row,
|
|
619
|
+
bindings: (node) => {
|
|
620
|
+
const properties = node.properties;
|
|
621
|
+
return [
|
|
622
|
+
inputBinding('alignment', () => properties.alignment ?? 'stretch'),
|
|
623
|
+
inputBinding('distribution', () => properties.distribution ?? 'start'),
|
|
624
|
+
];
|
|
625
|
+
},
|
|
626
|
+
},
|
|
627
|
+
Column: {
|
|
628
|
+
type: () => Column,
|
|
629
|
+
bindings: (node) => {
|
|
630
|
+
const properties = node.properties;
|
|
631
|
+
return [
|
|
632
|
+
inputBinding('alignment', () => properties.alignment ?? 'stretch'),
|
|
633
|
+
inputBinding('distribution', () => properties.distribution ?? 'start'),
|
|
634
|
+
];
|
|
635
|
+
},
|
|
636
|
+
},
|
|
637
|
+
List: {
|
|
638
|
+
type: () => import('./a2ui-angular-list-nEeT59V3.mjs').then((r) => r.List),
|
|
639
|
+
bindings: (node) => {
|
|
640
|
+
const properties = node.properties;
|
|
641
|
+
return [inputBinding('direction', () => properties.direction ?? 'vertical')];
|
|
642
|
+
},
|
|
643
|
+
},
|
|
644
|
+
Card: () => import('./a2ui-angular-card-Ix6OIdUv.mjs').then((r) => r.Card),
|
|
645
|
+
Image: {
|
|
646
|
+
type: () => import('./a2ui-angular-image-BWzAw0rh.mjs').then((r) => r.Image),
|
|
647
|
+
bindings: (node) => {
|
|
648
|
+
const properties = node.properties;
|
|
649
|
+
return [
|
|
650
|
+
inputBinding('url', () => properties.url),
|
|
651
|
+
inputBinding('usageHint', () => properties.usageHint),
|
|
652
|
+
];
|
|
653
|
+
},
|
|
654
|
+
},
|
|
655
|
+
Icon: {
|
|
656
|
+
type: () => import('./a2ui-angular-icon-BE9Hj9V6.mjs').then((r) => r.Icon),
|
|
657
|
+
bindings: (node) => {
|
|
658
|
+
const properties = node.properties;
|
|
659
|
+
return [inputBinding('name', () => properties.name)];
|
|
660
|
+
},
|
|
661
|
+
},
|
|
662
|
+
Video: {
|
|
663
|
+
type: () => import('./a2ui-angular-video-DuFTfN0B.mjs').then((r) => r.Video),
|
|
664
|
+
bindings: (node) => {
|
|
665
|
+
const properties = node.properties;
|
|
666
|
+
return [inputBinding('url', () => properties.url)];
|
|
667
|
+
},
|
|
668
|
+
},
|
|
669
|
+
AudioPlayer: {
|
|
670
|
+
type: () => import('./a2ui-angular-audio-DoZb9mn_.mjs').then((r) => r.Audio),
|
|
671
|
+
bindings: (node) => {
|
|
672
|
+
const properties = node.properties;
|
|
673
|
+
return [inputBinding('url', () => properties.url)];
|
|
674
|
+
},
|
|
675
|
+
},
|
|
676
|
+
Text: {
|
|
677
|
+
type: () => Text,
|
|
678
|
+
bindings: (node) => {
|
|
679
|
+
const properties = node.properties;
|
|
680
|
+
return [
|
|
681
|
+
inputBinding('text', () => properties.text),
|
|
682
|
+
inputBinding('usageHint', () => properties.usageHint || null),
|
|
683
|
+
];
|
|
684
|
+
},
|
|
685
|
+
},
|
|
686
|
+
Button: {
|
|
687
|
+
type: () => import('./a2ui-angular-button-CvH0kAtN.mjs').then((r) => r.Button),
|
|
688
|
+
bindings: (node) => {
|
|
689
|
+
const properties = node.properties;
|
|
690
|
+
return [inputBinding('action', () => properties.action)];
|
|
691
|
+
},
|
|
692
|
+
},
|
|
693
|
+
Divider: () => import('./a2ui-angular-divider-BizPl3qL.mjs').then((r) => r.Divider),
|
|
694
|
+
MultipleChoice: {
|
|
695
|
+
type: () => import('./a2ui-angular-multiple-choice-Bry7X74i.mjs').then((r) => r.MultipleChoice),
|
|
696
|
+
bindings: (node) => {
|
|
697
|
+
const properties = node.properties;
|
|
698
|
+
return [
|
|
699
|
+
inputBinding('options', () => properties.options || []),
|
|
700
|
+
inputBinding('value', () => properties.selections),
|
|
701
|
+
inputBinding('description', () => 'Select an item'), // TODO: this should be defined in the properties
|
|
702
|
+
];
|
|
703
|
+
},
|
|
704
|
+
},
|
|
705
|
+
TextField: {
|
|
706
|
+
type: () => import('./a2ui-angular-text-field-Deokh07j.mjs').then((r) => r.TextField),
|
|
707
|
+
bindings: (node) => {
|
|
708
|
+
const properties = node.properties;
|
|
709
|
+
return [
|
|
710
|
+
inputBinding('text', () => properties.text ?? null),
|
|
711
|
+
inputBinding('label', () => properties.label),
|
|
712
|
+
inputBinding('inputType', () => properties.type),
|
|
713
|
+
];
|
|
714
|
+
},
|
|
715
|
+
},
|
|
716
|
+
DateTimeInput: {
|
|
717
|
+
type: () => import('./a2ui-angular-datetime-input-dmZAjvrF.mjs').then((r) => r.DatetimeInput),
|
|
718
|
+
bindings: (node) => {
|
|
719
|
+
const properties = node.properties;
|
|
720
|
+
return [
|
|
721
|
+
inputBinding('enableDate', () => properties.enableDate),
|
|
722
|
+
inputBinding('enableTime', () => properties.enableTime),
|
|
723
|
+
inputBinding('value', () => properties.value),
|
|
724
|
+
];
|
|
725
|
+
},
|
|
726
|
+
},
|
|
727
|
+
CheckBox: {
|
|
728
|
+
type: () => import('./a2ui-angular-checkbox-BN4EF2Ci.mjs').then((r) => r.Checkbox),
|
|
729
|
+
bindings: (node) => {
|
|
730
|
+
const properties = node.properties;
|
|
731
|
+
return [
|
|
732
|
+
inputBinding('label', () => properties.label),
|
|
733
|
+
inputBinding('value', () => properties.value),
|
|
734
|
+
];
|
|
735
|
+
},
|
|
736
|
+
},
|
|
737
|
+
Slider: {
|
|
738
|
+
type: () => import('./a2ui-angular-slider-BgseUbN2.mjs').then((r) => r.Slider),
|
|
739
|
+
bindings: (node) => {
|
|
740
|
+
const properties = node.properties;
|
|
741
|
+
return [
|
|
742
|
+
inputBinding('value', () => properties.value),
|
|
743
|
+
inputBinding('minValue', () => properties.minValue),
|
|
744
|
+
inputBinding('maxValue', () => properties.maxValue),
|
|
745
|
+
inputBinding('label', () => ''), // TODO: this should be defined in the properties
|
|
746
|
+
];
|
|
747
|
+
},
|
|
748
|
+
},
|
|
749
|
+
Tabs: {
|
|
750
|
+
type: () => import('./a2ui-angular-tabs-q5Mn9vgq.mjs').then((r) => r.Tabs),
|
|
751
|
+
bindings: (node) => {
|
|
752
|
+
const properties = node.properties;
|
|
753
|
+
return [inputBinding('tabs', () => properties.tabItems)];
|
|
754
|
+
},
|
|
755
|
+
},
|
|
756
|
+
Modal: {
|
|
757
|
+
type: () => import('./a2ui-angular-modal-mr9LmczA.mjs').then((r) => r.Modal),
|
|
758
|
+
bindings: () => [],
|
|
759
|
+
},
|
|
760
|
+
};
|
|
761
|
+
|
|
762
|
+
/*
|
|
763
|
+
Copyright 2025 Google LLC
|
|
764
|
+
|
|
765
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
766
|
+
you may not use this file except in compliance with the License.
|
|
767
|
+
You may obtain a copy of the License at
|
|
768
|
+
|
|
769
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
770
|
+
|
|
771
|
+
Unless required by applicable law or agreed to in writing, software
|
|
772
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
773
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
774
|
+
See the License for the specific language governing permissions and
|
|
775
|
+
limitations under the License.
|
|
776
|
+
*/
|
|
777
|
+
class Surface {
|
|
778
|
+
surfaceId = input.required(...(ngDevMode ? [{ debugName: "surfaceId" }] : []));
|
|
779
|
+
surface = input.required(...(ngDevMode ? [{ debugName: "surface" }] : []));
|
|
780
|
+
styles = computed(() => {
|
|
781
|
+
const surface = this.surface();
|
|
782
|
+
const styles = {};
|
|
783
|
+
if (surface?.styles) {
|
|
784
|
+
for (const [key, value] of Object.entries(surface.styles)) {
|
|
785
|
+
switch (key) {
|
|
786
|
+
// Here we generate a palette from the singular primary color received
|
|
787
|
+
// from the surface data. We will want the values to range from
|
|
788
|
+
// 0 <= x <= 100, where 0 = back, 100 = white, and 50 = the primary
|
|
789
|
+
// color itself. As such we use a color-mix to create the intermediate
|
|
790
|
+
// values.
|
|
791
|
+
//
|
|
792
|
+
// Note: since we use half the range for black to the primary color,
|
|
793
|
+
// and half the range for primary color to white the mixed values have
|
|
794
|
+
// to go up double the amount, i.e., a range from black to primary
|
|
795
|
+
// color needs to fit in 0 -> 50 rather than 0 -> 100.
|
|
796
|
+
case 'primaryColor': {
|
|
797
|
+
styles['--p-100'] = '#ffffff';
|
|
798
|
+
styles['--p-99'] = `color-mix(in srgb, ${value} 2%, white 98%)`;
|
|
799
|
+
styles['--p-98'] = `color-mix(in srgb, ${value} 4%, white 96%)`;
|
|
800
|
+
styles['--p-95'] = `color-mix(in srgb, ${value} 10%, white 90%)`;
|
|
801
|
+
styles['--p-90'] = `color-mix(in srgb, ${value} 20%, white 80%)`;
|
|
802
|
+
styles['--p-80'] = `color-mix(in srgb, ${value} 40%, white 60%)`;
|
|
803
|
+
styles['--p-70'] = `color-mix(in srgb, ${value} 60%, white 40%)`;
|
|
804
|
+
styles['--p-60'] = `color-mix(in srgb, ${value} 80%, white 20%)`;
|
|
805
|
+
styles['--p-50'] = value;
|
|
806
|
+
styles['--p-40'] = `color-mix(in srgb, ${value} 80%, black 20%)`;
|
|
807
|
+
styles['--p-35'] = `color-mix(in srgb, ${value} 70%, black 30%)`;
|
|
808
|
+
styles['--p-30'] = `color-mix(in srgb, ${value} 60%, black 40%)`;
|
|
809
|
+
styles['--p-25'] = `color-mix(in srgb, ${value} 50%, black 50%)`;
|
|
810
|
+
styles['--p-20'] = `color-mix(in srgb, ${value} 40%, black 60%)`;
|
|
811
|
+
styles['--p-15'] = `color-mix(in srgb, ${value} 30%, black 70%)`;
|
|
812
|
+
styles['--p-10'] = `color-mix(in srgb, ${value} 20%, black 80%)`;
|
|
813
|
+
styles['--p-5'] = `color-mix(in srgb, ${value} 10%, black 90%)`;
|
|
814
|
+
styles['--0'] = '#00000';
|
|
815
|
+
break;
|
|
816
|
+
}
|
|
817
|
+
case 'font': {
|
|
818
|
+
styles['--font-family'] = value;
|
|
819
|
+
styles['--font-family-flex'] = value;
|
|
820
|
+
break;
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
return styles;
|
|
826
|
+
}, ...(ngDevMode ? [{ debugName: "styles" }] : []));
|
|
827
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: Surface, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
828
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.3", type: Surface, isStandalone: true, selector: "a2ui-surface", inputs: { surfaceId: { classPropertyName: "surfaceId", publicName: "surfaceId", isSignal: true, isRequired: true, transformFunction: null }, surface: { classPropertyName: "surface", publicName: "surface", isSignal: true, isRequired: true, transformFunction: null } }, host: { properties: { "style": "styles()" } }, ngImport: i0, template: `
|
|
829
|
+
@let surfaceId = this.surfaceId();
|
|
830
|
+
@let surface = this.surface();
|
|
831
|
+
|
|
832
|
+
@if (surfaceId && surface) {
|
|
833
|
+
<ng-container a2ui-renderer [surfaceId]="surfaceId" [component]="surface.componentTree!" />
|
|
834
|
+
}
|
|
835
|
+
`, isInline: true, styles: [":host{display:flex;min-height:0;max-height:100%;flex-direction:column;gap:16px}\n"], dependencies: [{ kind: "directive", type: Renderer, selector: "ng-container[a2ui-renderer]", inputs: ["surfaceId", "component"] }] });
|
|
836
|
+
}
|
|
837
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: Surface, decorators: [{
|
|
838
|
+
type: Component,
|
|
839
|
+
args: [{ selector: 'a2ui-surface', imports: [Renderer], template: `
|
|
840
|
+
@let surfaceId = this.surfaceId();
|
|
841
|
+
@let surface = this.surface();
|
|
842
|
+
|
|
843
|
+
@if (surfaceId && surface) {
|
|
844
|
+
<ng-container a2ui-renderer [surfaceId]="surfaceId" [component]="surface.componentTree!" />
|
|
845
|
+
}
|
|
846
|
+
`, host: {
|
|
847
|
+
'[style]': 'styles()',
|
|
848
|
+
}, styles: [":host{display:flex;min-height:0;max-height:100%;flex-direction:column;gap:16px}\n"] }]
|
|
849
|
+
}], propDecorators: { surfaceId: [{ type: i0.Input, args: [{ isSignal: true, alias: "surfaceId", required: true }] }], surface: [{ type: i0.Input, args: [{ isSignal: true, alias: "surface", required: true }] }] } });
|
|
850
|
+
|
|
851
|
+
/*
|
|
852
|
+
Copyright 2025 Google LLC
|
|
853
|
+
|
|
854
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
855
|
+
you may not use this file except in compliance with the License.
|
|
856
|
+
You may obtain a copy of the License at
|
|
857
|
+
|
|
858
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
859
|
+
|
|
860
|
+
Unless required by applicable law or agreed to in writing, software
|
|
861
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
862
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
863
|
+
See the License for the specific language governing permissions and
|
|
864
|
+
limitations under the License.
|
|
865
|
+
*/
|
|
866
|
+
|
|
867
|
+
/**
|
|
868
|
+
* Generated bundle index. Do not edit.
|
|
869
|
+
*/
|
|
870
|
+
|
|
871
|
+
export { Catalog, DEFAULT_CATALOG, DynamicComponent, MessageProcessor, Renderer, Surface, Theme, provideA2UI };
|
|
872
|
+
//# sourceMappingURL=a2ui-angular.mjs.map
|