@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
package/src/lib/catalog/modal.ts
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2025 Google LLC
|
|
3
|
-
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
|
|
8
|
-
https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { Component, signal, viewChild, ElementRef, effect } from '@angular/core';
|
|
18
|
-
import { DynamicComponent } from '../rendering/dynamic-component';
|
|
19
|
-
import { Types } from '@a2ui/lit/0.8';
|
|
20
|
-
import { Renderer } from '../rendering';
|
|
21
|
-
|
|
22
|
-
@Component({
|
|
23
|
-
selector: 'a2ui-modal',
|
|
24
|
-
imports: [Renderer],
|
|
25
|
-
template: `
|
|
26
|
-
@if (showDialog()) {
|
|
27
|
-
<dialog #dialog [class]="theme.components.Modal.backdrop" (click)="handleDialogClick($event)">
|
|
28
|
-
<section [class]="theme.components.Modal.element" [style]="theme.additionalStyles?.Modal">
|
|
29
|
-
<div class="controls">
|
|
30
|
-
<button (click)="closeDialog()">
|
|
31
|
-
<span class="g-icon">close</span>
|
|
32
|
-
</button>
|
|
33
|
-
</div>
|
|
34
|
-
|
|
35
|
-
<ng-container
|
|
36
|
-
a2ui-renderer
|
|
37
|
-
[surfaceId]="surfaceId()!"
|
|
38
|
-
[component]="component().properties.contentChild"
|
|
39
|
-
/>
|
|
40
|
-
</section>
|
|
41
|
-
</dialog>
|
|
42
|
-
} @else {
|
|
43
|
-
<section (click)="showDialog.set(true)">
|
|
44
|
-
<ng-container
|
|
45
|
-
a2ui-renderer
|
|
46
|
-
[surfaceId]="surfaceId()!"
|
|
47
|
-
[component]="component().properties.entryPointChild"
|
|
48
|
-
/>
|
|
49
|
-
</section>
|
|
50
|
-
}
|
|
51
|
-
`,
|
|
52
|
-
styles: `
|
|
53
|
-
dialog {
|
|
54
|
-
padding: 0;
|
|
55
|
-
border: none;
|
|
56
|
-
background: none;
|
|
57
|
-
|
|
58
|
-
& section {
|
|
59
|
-
& .controls {
|
|
60
|
-
display: flex;
|
|
61
|
-
justify-content: end;
|
|
62
|
-
margin-bottom: 4px;
|
|
63
|
-
|
|
64
|
-
& button {
|
|
65
|
-
padding: 0;
|
|
66
|
-
background: none;
|
|
67
|
-
width: 20px;
|
|
68
|
-
height: 20px;
|
|
69
|
-
pointer: cursor;
|
|
70
|
-
border: none;
|
|
71
|
-
cursor: pointer;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
`,
|
|
77
|
-
})
|
|
78
|
-
export class Modal extends DynamicComponent<Types.ModalNode> {
|
|
79
|
-
protected readonly showDialog = signal(false);
|
|
80
|
-
protected readonly dialog = viewChild<ElementRef<HTMLDialogElement>>('dialog');
|
|
81
|
-
|
|
82
|
-
constructor() {
|
|
83
|
-
super();
|
|
84
|
-
|
|
85
|
-
effect(() => {
|
|
86
|
-
const dialog = this.dialog();
|
|
87
|
-
|
|
88
|
-
if (dialog && !dialog.nativeElement.open) {
|
|
89
|
-
dialog.nativeElement.showModal();
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
protected handleDialogClick(event: MouseEvent) {
|
|
95
|
-
if (event.target instanceof HTMLDialogElement) {
|
|
96
|
-
this.closeDialog();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
protected closeDialog() {
|
|
101
|
-
const dialog = this.dialog();
|
|
102
|
-
|
|
103
|
-
if (!dialog) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (!dialog.nativeElement.open) {
|
|
108
|
-
dialog.nativeElement.close();
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
this.showDialog.set(false);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2025 Google LLC
|
|
3
|
-
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
|
|
8
|
-
https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { Component, computed, input } from '@angular/core';
|
|
18
|
-
import { DynamicComponent } from '../rendering/dynamic-component';
|
|
19
|
-
import { Primitives } from '@a2ui/lit/0.8';
|
|
20
|
-
|
|
21
|
-
@Component({
|
|
22
|
-
selector: 'a2ui-multiple-choice',
|
|
23
|
-
template: `
|
|
24
|
-
<section [class]="theme.components.MultipleChoice.container">
|
|
25
|
-
<label [class]="theme.components.MultipleChoice.label" [for]="selectId">{{
|
|
26
|
-
description()
|
|
27
|
-
}}</label>
|
|
28
|
-
|
|
29
|
-
<select
|
|
30
|
-
(change)="handleChange($event)"
|
|
31
|
-
[id]="selectId"
|
|
32
|
-
[value]="selectValue()"
|
|
33
|
-
[class]="theme.components.MultipleChoice.element"
|
|
34
|
-
[style]="theme.additionalStyles?.MultipleChoice"
|
|
35
|
-
>
|
|
36
|
-
@for (option of options(); track option.value) {
|
|
37
|
-
<option [value]="option.value">{{ resolvePrimitive(option.label) }}</option>
|
|
38
|
-
}
|
|
39
|
-
</select>
|
|
40
|
-
</section>
|
|
41
|
-
`,
|
|
42
|
-
styles: `
|
|
43
|
-
:host {
|
|
44
|
-
display: block;
|
|
45
|
-
flex: var(--weight);
|
|
46
|
-
min-height: 0;
|
|
47
|
-
overflow: auto;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
select {
|
|
51
|
-
width: 100%;
|
|
52
|
-
box-sizing: border-box;
|
|
53
|
-
}
|
|
54
|
-
`,
|
|
55
|
-
})
|
|
56
|
-
export class MultipleChoice extends DynamicComponent {
|
|
57
|
-
readonly options = input.required<{ label: Primitives.StringValue; value: string }[]>();
|
|
58
|
-
readonly value = input.required<Primitives.StringValue | null>();
|
|
59
|
-
readonly description = input.required<string>();
|
|
60
|
-
|
|
61
|
-
protected readonly selectId = super.getUniqueId('a2ui-multiple-choice');
|
|
62
|
-
protected selectValue = computed(() => super.resolvePrimitive(this.value()));
|
|
63
|
-
|
|
64
|
-
protected handleChange(event: Event) {
|
|
65
|
-
const path = this.value()?.path;
|
|
66
|
-
|
|
67
|
-
if (!(event.target instanceof HTMLSelectElement) || !event.target.value || !path) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
this.processor.setData(
|
|
72
|
-
this.component(),
|
|
73
|
-
this.processor.resolvePath(path, this.component().dataContextPath),
|
|
74
|
-
event.target.value,
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
}
|
package/src/lib/catalog/row.ts
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2025 Google LLC
|
|
3
|
-
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
|
|
8
|
-
https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { Component, computed, input } from '@angular/core';
|
|
18
|
-
import { DynamicComponent } from '../rendering/dynamic-component';
|
|
19
|
-
import { Renderer } from '../rendering/renderer';
|
|
20
|
-
import { Types } from '@a2ui/lit/0.8';
|
|
21
|
-
|
|
22
|
-
@Component({
|
|
23
|
-
selector: 'a2ui-row',
|
|
24
|
-
imports: [Renderer],
|
|
25
|
-
host: {
|
|
26
|
-
'[attr.alignment]': 'alignment()',
|
|
27
|
-
'[attr.distribution]': 'distribution()',
|
|
28
|
-
},
|
|
29
|
-
styles: `
|
|
30
|
-
:host {
|
|
31
|
-
display: flex;
|
|
32
|
-
flex: var(--weight);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
section {
|
|
36
|
-
display: flex;
|
|
37
|
-
flex-direction: row;
|
|
38
|
-
width: 100%;
|
|
39
|
-
min-height: 100%;
|
|
40
|
-
box-sizing: border-box;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.align-start {
|
|
44
|
-
align-items: start;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.align-center {
|
|
48
|
-
align-items: center;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.align-end {
|
|
52
|
-
align-items: end;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.align-stretch {
|
|
56
|
-
align-items: stretch;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.distribute-start {
|
|
60
|
-
justify-content: start;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.distribute-center {
|
|
64
|
-
justify-content: center;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.distribute-end {
|
|
68
|
-
justify-content: end;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.distribute-spaceBetween {
|
|
72
|
-
justify-content: space-between;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.distribute-spaceAround {
|
|
76
|
-
justify-content: space-around;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.distribute-spaceEvenly {
|
|
80
|
-
justify-content: space-evenly;
|
|
81
|
-
}
|
|
82
|
-
`,
|
|
83
|
-
template: `
|
|
84
|
-
<section [class]="classes()" [style]="theme.additionalStyles?.Row">
|
|
85
|
-
@for (child of component().properties.children; track child) {
|
|
86
|
-
<ng-container a2ui-renderer [surfaceId]="surfaceId()!" [component]="child" />
|
|
87
|
-
}
|
|
88
|
-
</section>
|
|
89
|
-
`,
|
|
90
|
-
})
|
|
91
|
-
export class Row extends DynamicComponent<Types.RowNode> {
|
|
92
|
-
readonly alignment = input<Types.ResolvedRow['alignment']>('stretch');
|
|
93
|
-
readonly distribution = input<Types.ResolvedRow['distribution']>('start');
|
|
94
|
-
|
|
95
|
-
protected readonly classes = computed(() => ({
|
|
96
|
-
...this.theme.components.Row,
|
|
97
|
-
[`align-${this.alignment()}`]: true,
|
|
98
|
-
[`distribute-${this.distribution()}`]: true,
|
|
99
|
-
}));
|
|
100
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2025 Google LLC
|
|
3
|
-
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
|
|
8
|
-
https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { Component, computed, input } from '@angular/core';
|
|
18
|
-
import { Primitives } from '@a2ui/lit/0.8';
|
|
19
|
-
import { DynamicComponent } from '../rendering/dynamic-component';
|
|
20
|
-
|
|
21
|
-
@Component({
|
|
22
|
-
selector: '[a2ui-slider]',
|
|
23
|
-
template: `
|
|
24
|
-
<section [class]="theme.components.Slider.container">
|
|
25
|
-
<label [class]="theme.components.Slider.label" [for]="inputId">
|
|
26
|
-
{{ label() }}
|
|
27
|
-
</label>
|
|
28
|
-
|
|
29
|
-
<input
|
|
30
|
-
autocomplete="off"
|
|
31
|
-
type="range"
|
|
32
|
-
[value]="resolvedValue()"
|
|
33
|
-
[min]="minValue()"
|
|
34
|
-
[max]="maxValue()"
|
|
35
|
-
[id]="inputId"
|
|
36
|
-
(input)="handleInput($event)"
|
|
37
|
-
[class]="theme.components.Slider.element"
|
|
38
|
-
[style]="theme.additionalStyles?.Slider"
|
|
39
|
-
/>
|
|
40
|
-
</section>
|
|
41
|
-
`,
|
|
42
|
-
styles: `
|
|
43
|
-
:host {
|
|
44
|
-
display: block;
|
|
45
|
-
flex: var(--weight);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
input {
|
|
49
|
-
display: block;
|
|
50
|
-
width: 100%;
|
|
51
|
-
box-sizing: border-box;
|
|
52
|
-
}
|
|
53
|
-
`,
|
|
54
|
-
})
|
|
55
|
-
export class Slider extends DynamicComponent {
|
|
56
|
-
readonly value = input.required<Primitives.NumberValue | null>();
|
|
57
|
-
readonly label = input('');
|
|
58
|
-
readonly minValue = input.required<number | undefined>();
|
|
59
|
-
readonly maxValue = input.required<number | undefined>();
|
|
60
|
-
|
|
61
|
-
protected readonly inputId = super.getUniqueId('a2ui-slider');
|
|
62
|
-
protected resolvedValue = computed(() => super.resolvePrimitive(this.value()) ?? 0);
|
|
63
|
-
|
|
64
|
-
protected handleInput(event: Event) {
|
|
65
|
-
const path = this.value()?.path;
|
|
66
|
-
|
|
67
|
-
if (!(event.target instanceof HTMLInputElement) || !path) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
this.processor.setData(this.component(), path, event.target.valueAsNumber, this.surfaceId());
|
|
72
|
-
}
|
|
73
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2025 Google LLC
|
|
3
|
-
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
|
|
8
|
-
https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { Component, computed, input } from '@angular/core';
|
|
18
|
-
import { Types } from '@a2ui/lit/0.8';
|
|
19
|
-
import { Renderer } from '../rendering/renderer';
|
|
20
|
-
|
|
21
|
-
@Component({
|
|
22
|
-
selector: 'a2ui-surface',
|
|
23
|
-
imports: [Renderer],
|
|
24
|
-
template: `
|
|
25
|
-
@let surfaceId = this.surfaceId();
|
|
26
|
-
@let surface = this.surface();
|
|
27
|
-
|
|
28
|
-
@if (surfaceId && surface) {
|
|
29
|
-
<ng-container a2ui-renderer [surfaceId]="surfaceId" [component]="surface.componentTree!" />
|
|
30
|
-
}
|
|
31
|
-
`,
|
|
32
|
-
styles: `
|
|
33
|
-
:host {
|
|
34
|
-
display: flex;
|
|
35
|
-
min-height: 0;
|
|
36
|
-
max-height: 100%;
|
|
37
|
-
flex-direction: column;
|
|
38
|
-
gap: 16px;
|
|
39
|
-
}
|
|
40
|
-
`,
|
|
41
|
-
host: {
|
|
42
|
-
'[style]': 'styles()',
|
|
43
|
-
},
|
|
44
|
-
})
|
|
45
|
-
export class Surface {
|
|
46
|
-
readonly surfaceId = input.required<Types.SurfaceID | null>();
|
|
47
|
-
readonly surface = input.required<Types.Surface | null>();
|
|
48
|
-
|
|
49
|
-
protected readonly styles = computed(() => {
|
|
50
|
-
const surface = this.surface();
|
|
51
|
-
const styles: Record<string, string> = {};
|
|
52
|
-
|
|
53
|
-
if (surface?.styles) {
|
|
54
|
-
for (const [key, value] of Object.entries(surface.styles)) {
|
|
55
|
-
switch (key) {
|
|
56
|
-
case 'primaryColor': {
|
|
57
|
-
// Ignored for now. This is due to the fact that the sample agents
|
|
58
|
-
// produce values for these and if they are used here then they will
|
|
59
|
-
// override the values at the app level.
|
|
60
|
-
//
|
|
61
|
-
// for (let i = 0; i <= 100; i++) {
|
|
62
|
-
// styles[`--p-${i}`] = `color-mix(in srgb, ${value} ${100 - i}%, #fff ${i}%)`;
|
|
63
|
-
// }
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
case 'font': {
|
|
68
|
-
// Ignored for now. This is due to the fact that the sample agents
|
|
69
|
-
// produce values for these and if they are used here then they will
|
|
70
|
-
// override the values at the app level.
|
|
71
|
-
//
|
|
72
|
-
// styles['--font-family'] = value;
|
|
73
|
-
// styles['--font-family-flex'] = value;
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return styles;
|
|
81
|
-
});
|
|
82
|
-
}
|
package/src/lib/catalog/tabs.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2025 Google LLC
|
|
3
|
-
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
|
|
8
|
-
https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { Component, computed, input, signal } from '@angular/core';
|
|
18
|
-
import { DynamicComponent } from '../rendering/dynamic-component';
|
|
19
|
-
import { Renderer } from '../rendering/renderer';
|
|
20
|
-
import { Styles, Types } from '@a2ui/lit/0.8';
|
|
21
|
-
|
|
22
|
-
@Component({
|
|
23
|
-
selector: 'a2ui-tabs',
|
|
24
|
-
imports: [Renderer],
|
|
25
|
-
template: `
|
|
26
|
-
@let tabs = this.tabs();
|
|
27
|
-
@let selectedIndex = this.selectedIndex();
|
|
28
|
-
|
|
29
|
-
<section [class]="theme.components.Tabs.container" [style]="theme.additionalStyles?.Tabs">
|
|
30
|
-
<div [class]="theme.components.Tabs.element">
|
|
31
|
-
@for (tab of tabs; track tab) {
|
|
32
|
-
<button
|
|
33
|
-
(click)="this.selectedIndex.set($index)"
|
|
34
|
-
[disabled]="selectedIndex === $index"
|
|
35
|
-
[class]="buttonClasses()[selectedIndex]"
|
|
36
|
-
>
|
|
37
|
-
{{ resolvePrimitive(tab.title) }}
|
|
38
|
-
</button>
|
|
39
|
-
}
|
|
40
|
-
</div>
|
|
41
|
-
|
|
42
|
-
<ng-container
|
|
43
|
-
a2ui-renderer
|
|
44
|
-
[surfaceId]="surfaceId()!"
|
|
45
|
-
[component]="tabs[selectedIndex].child"
|
|
46
|
-
/>
|
|
47
|
-
</section>
|
|
48
|
-
`,
|
|
49
|
-
styles: `
|
|
50
|
-
:host {
|
|
51
|
-
display: block;
|
|
52
|
-
flex: var(--weight);
|
|
53
|
-
}
|
|
54
|
-
`,
|
|
55
|
-
})
|
|
56
|
-
export class Tabs extends DynamicComponent {
|
|
57
|
-
protected selectedIndex = signal(0);
|
|
58
|
-
readonly tabs = input.required<Types.ResolvedTabItem[]>();
|
|
59
|
-
|
|
60
|
-
protected readonly buttonClasses = computed(() => {
|
|
61
|
-
const selectedIndex = this.selectedIndex();
|
|
62
|
-
|
|
63
|
-
return this.tabs().map((_, index) => {
|
|
64
|
-
return index === selectedIndex
|
|
65
|
-
? Styles.merge(
|
|
66
|
-
this.theme.components.Tabs.controls.all,
|
|
67
|
-
this.theme.components.Tabs.controls.selected,
|
|
68
|
-
)
|
|
69
|
-
: this.theme.components.Tabs.controls.all;
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2025 Google LLC
|
|
3
|
-
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
|
|
8
|
-
https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { computed, Component, input } from '@angular/core';
|
|
18
|
-
import { Primitives, Types } from '@a2ui/lit/0.8';
|
|
19
|
-
import { DynamicComponent } from '../rendering/dynamic-component';
|
|
20
|
-
|
|
21
|
-
@Component({
|
|
22
|
-
selector: 'a2ui-text-field',
|
|
23
|
-
styles: `
|
|
24
|
-
:host {
|
|
25
|
-
display: flex;
|
|
26
|
-
flex: var(--weight);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
section,
|
|
30
|
-
input,
|
|
31
|
-
label {
|
|
32
|
-
box-sizing: border-box;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
input {
|
|
36
|
-
display: block;
|
|
37
|
-
width: 100%;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
label {
|
|
41
|
-
display: block;
|
|
42
|
-
margin-bottom: 4px;
|
|
43
|
-
}
|
|
44
|
-
`,
|
|
45
|
-
template: `
|
|
46
|
-
@let resolvedLabel = this.resolvedLabel();
|
|
47
|
-
|
|
48
|
-
<section [class]="theme.components.TextField.container">
|
|
49
|
-
@if (resolvedLabel) {
|
|
50
|
-
<label [for]="inputId" [class]="theme.components.TextField.label">{{
|
|
51
|
-
resolvedLabel
|
|
52
|
-
}}</label>
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
<input
|
|
56
|
-
autocomplete="off"
|
|
57
|
-
[class]="theme.components.TextField.element"
|
|
58
|
-
[style]="theme.additionalStyles?.TextField"
|
|
59
|
-
(input)="handleInput($event)"
|
|
60
|
-
[id]="inputId"
|
|
61
|
-
[value]="inputValue()"
|
|
62
|
-
placeholder="Please enter a value"
|
|
63
|
-
[type]="inputType() === 'number' ? 'number' : 'text'"
|
|
64
|
-
/>
|
|
65
|
-
</section>
|
|
66
|
-
`,
|
|
67
|
-
})
|
|
68
|
-
export class TextField extends DynamicComponent {
|
|
69
|
-
readonly text = input.required<Primitives.StringValue | null>();
|
|
70
|
-
readonly label = input.required<Primitives.StringValue | null>();
|
|
71
|
-
readonly inputType = input.required<Types.ResolvedTextField['type'] | null>();
|
|
72
|
-
|
|
73
|
-
protected inputValue = computed(() => super.resolvePrimitive(this.text()) || '');
|
|
74
|
-
protected resolvedLabel = computed(() => super.resolvePrimitive(this.label()));
|
|
75
|
-
protected inputId = super.getUniqueId('a2ui-input');
|
|
76
|
-
|
|
77
|
-
protected handleInput(event: Event) {
|
|
78
|
-
const path = this.text()?.path;
|
|
79
|
-
|
|
80
|
-
if (!(event.target instanceof HTMLInputElement) || !path) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
this.processor.setData(this.component(), path, event.target.value, this.surfaceId());
|
|
85
|
-
}
|
|
86
|
-
}
|