@ai-composer/angular 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +6 -0
- package/dist/index.d.ts +82 -0
- package/dist/index.js +354 -0
- package/package.json +33 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Deepak Chopkar
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ai-composer/angular — Angular adapter (standalone components + signals).
|
|
3
|
+
*
|
|
4
|
+
* ```html
|
|
5
|
+
* <aic-ai-composer [editor]="editor" mode="chat" placeholder="Ask anything…"
|
|
6
|
+
* (submitted)="onSubmit($event)">
|
|
7
|
+
* <div aic-header>Context</div>
|
|
8
|
+
* <aic-ai-composer-input />
|
|
9
|
+
* <div aic-toolbar><aic-ai-composer-submit /></div>
|
|
10
|
+
* </aic-ai-composer>
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
import { AfterViewInit, ElementRef, EventEmitter, OnChanges, OnDestroy, OnInit, SimpleChanges, Signal } from '@angular/core';
|
|
14
|
+
import { ControlValueAccessor } from '@angular/forms';
|
|
15
|
+
import { type AIComposerDocument, type AIComposer, type AIComposerOptions, type AIComposerState } from '@ai-composer/core';
|
|
16
|
+
/** Per-<aic-ai-composer> DI holder so projected children reach the editor. */
|
|
17
|
+
export declare class AiComposerEditorHolder {
|
|
18
|
+
editor: AIComposer | null;
|
|
19
|
+
}
|
|
20
|
+
/** Resolve the editor from the enclosing <aic-ai-composer>. */
|
|
21
|
+
export declare function injectAIComposer(): AIComposer;
|
|
22
|
+
/** Live editor state as a signal (re-evaluated on every editor notify). */
|
|
23
|
+
export declare function injectAIComposerState(): Signal<AIComposerState | null>;
|
|
24
|
+
export declare class AIComposerHeaderDirective {
|
|
25
|
+
}
|
|
26
|
+
export declare class AIComposerToolbarDirective {
|
|
27
|
+
}
|
|
28
|
+
export declare class AIComposerFooterDirective {
|
|
29
|
+
}
|
|
30
|
+
export declare class AIComposerAttachmentsDirective {
|
|
31
|
+
}
|
|
32
|
+
export declare class AIComposerComponent implements OnInit, OnChanges, OnDestroy, ControlValueAccessor {
|
|
33
|
+
private readonly holder;
|
|
34
|
+
/** External editor; when omitted one is created from `options`. */
|
|
35
|
+
editor: AIComposer | null;
|
|
36
|
+
options: AIComposerOptions | null;
|
|
37
|
+
mode: string;
|
|
38
|
+
placeholder: string;
|
|
39
|
+
disabled: boolean;
|
|
40
|
+
readonly: boolean;
|
|
41
|
+
/** Auto-height ceiling — px number or CSS length; scrolls after the cap. */
|
|
42
|
+
maxHeight: number | string;
|
|
43
|
+
valueChange: EventEmitter<AIComposerDocument>;
|
|
44
|
+
submitted: EventEmitter<AIComposerDocument>;
|
|
45
|
+
/** Custom toolbar projection (suppresses the default one). */
|
|
46
|
+
customToolbar: AIComposerToolbarDirective | null;
|
|
47
|
+
readonly state: import("@angular/core").WritableSignal<AIComposerState | null>;
|
|
48
|
+
/** Default circular send button for compact/chat/expanded (Copilot style). */
|
|
49
|
+
readonly showDefaultToolbar: Signal<boolean>;
|
|
50
|
+
private created;
|
|
51
|
+
private resolved;
|
|
52
|
+
private unsubscribe;
|
|
53
|
+
constructor(holder: AiComposerEditorHolder);
|
|
54
|
+
private get editorInstance();
|
|
55
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
56
|
+
ngOnInit(): void;
|
|
57
|
+
ngOnDestroy(): void;
|
|
58
|
+
/** Direct access for template code: {{ editor().serialize('text') }} */
|
|
59
|
+
getEditor(): AIComposer;
|
|
60
|
+
writeValue(value: unknown): void;
|
|
61
|
+
registerOnChange(fn: (value: AIComposerDocument) => void): void;
|
|
62
|
+
registerOnTouched(fn: () => void): void;
|
|
63
|
+
setDisabledState(isDisabled: boolean): void;
|
|
64
|
+
}
|
|
65
|
+
export declare class AIComposerInputComponent implements AfterViewInit, OnDestroy {
|
|
66
|
+
private readonly elementRef;
|
|
67
|
+
private readonly holder;
|
|
68
|
+
private surface;
|
|
69
|
+
private list;
|
|
70
|
+
constructor(elementRef: ElementRef<HTMLElement>);
|
|
71
|
+
ngAfterViewInit(): void;
|
|
72
|
+
ngOnDestroy(): void;
|
|
73
|
+
}
|
|
74
|
+
export declare class SubmitButtonComponent {
|
|
75
|
+
private readonly editor;
|
|
76
|
+
private readonly state;
|
|
77
|
+
readonly canSubmit: Signal<boolean>;
|
|
78
|
+
submit(): void;
|
|
79
|
+
}
|
|
80
|
+
/** Convenience import collection. */
|
|
81
|
+
export declare const AI_COMPOSER_IMPORTS: readonly [typeof AIComposerComponent, typeof AIComposerInputComponent, typeof SubmitButtonComponent, typeof AIComposerHeaderDirective, typeof AIComposerToolbarDirective, typeof AIComposerFooterDirective, typeof AIComposerAttachmentsDirective];
|
|
82
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ai-composer/angular — Angular adapter (standalone components + signals).
|
|
3
|
+
*
|
|
4
|
+
* ```html
|
|
5
|
+
* <aic-ai-composer [editor]="editor" mode="chat" placeholder="Ask anything…"
|
|
6
|
+
* (submitted)="onSubmit($event)">
|
|
7
|
+
* <div aic-header>Context</div>
|
|
8
|
+
* <aic-ai-composer-input />
|
|
9
|
+
* <div aic-toolbar><aic-ai-composer-submit /></div>
|
|
10
|
+
* </aic-ai-composer>
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
14
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
15
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
16
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
17
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
18
|
+
};
|
|
19
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
21
|
+
};
|
|
22
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
23
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
24
|
+
};
|
|
25
|
+
import { ChangeDetectionStrategy, Component, ContentChild, Directive, ElementRef, EventEmitter, Inject, Injectable, Input, Output, computed, forwardRef, inject, signal, } from '@angular/core';
|
|
26
|
+
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
27
|
+
import { coerceDocument, createAIComposer, isAIComposer, } from '@ai-composer/core';
|
|
28
|
+
import { createEditableSurface, createSuggestionList } from '@ai-composer/dom';
|
|
29
|
+
/** Per-<aic-ai-composer> DI holder so projected children reach the editor. */
|
|
30
|
+
let AiComposerEditorHolder = class AiComposerEditorHolder {
|
|
31
|
+
editor = null;
|
|
32
|
+
};
|
|
33
|
+
AiComposerEditorHolder = __decorate([
|
|
34
|
+
Injectable()
|
|
35
|
+
], AiComposerEditorHolder);
|
|
36
|
+
export { AiComposerEditorHolder };
|
|
37
|
+
/** Resolve the editor from the enclosing <aic-ai-composer>. */
|
|
38
|
+
export function injectAIComposer() {
|
|
39
|
+
const holder = inject(AiComposerEditorHolder);
|
|
40
|
+
if (!holder.editor) {
|
|
41
|
+
throw new Error('injectAIComposer() must be called inside <aic-ai-composer>');
|
|
42
|
+
}
|
|
43
|
+
return holder.editor;
|
|
44
|
+
}
|
|
45
|
+
/** Live editor state as a signal (re-evaluated on every editor notify). */
|
|
46
|
+
export function injectAIComposerState() {
|
|
47
|
+
const editor = injectAIComposer();
|
|
48
|
+
const state = signal(editor.getState());
|
|
49
|
+
// Cleanup rides on the root component destroying its editor.
|
|
50
|
+
editor.subscribe((next) => state.set(next));
|
|
51
|
+
return state.asReadonly();
|
|
52
|
+
}
|
|
53
|
+
// ---------------------------------------------------------------------------
|
|
54
|
+
// Slot marker directives (content projection anchors)
|
|
55
|
+
// ---------------------------------------------------------------------------
|
|
56
|
+
let AIComposerHeaderDirective = class AIComposerHeaderDirective {
|
|
57
|
+
};
|
|
58
|
+
AIComposerHeaderDirective = __decorate([
|
|
59
|
+
Directive({ selector: '[aic-header]', standalone: true })
|
|
60
|
+
], AIComposerHeaderDirective);
|
|
61
|
+
export { AIComposerHeaderDirective };
|
|
62
|
+
let AIComposerToolbarDirective = class AIComposerToolbarDirective {
|
|
63
|
+
};
|
|
64
|
+
AIComposerToolbarDirective = __decorate([
|
|
65
|
+
Directive({ selector: '[aic-toolbar]', standalone: true })
|
|
66
|
+
], AIComposerToolbarDirective);
|
|
67
|
+
export { AIComposerToolbarDirective };
|
|
68
|
+
let AIComposerFooterDirective = class AIComposerFooterDirective {
|
|
69
|
+
};
|
|
70
|
+
AIComposerFooterDirective = __decorate([
|
|
71
|
+
Directive({ selector: '[aic-footer]', standalone: true })
|
|
72
|
+
], AIComposerFooterDirective);
|
|
73
|
+
export { AIComposerFooterDirective };
|
|
74
|
+
let AIComposerAttachmentsDirective = class AIComposerAttachmentsDirective {
|
|
75
|
+
};
|
|
76
|
+
AIComposerAttachmentsDirective = __decorate([
|
|
77
|
+
Directive({ selector: '[aic-attachments]', standalone: true })
|
|
78
|
+
], AIComposerAttachmentsDirective);
|
|
79
|
+
export { AIComposerAttachmentsDirective };
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
81
|
+
// Root component
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
let AIComposerComponent = class AIComposerComponent {
|
|
84
|
+
holder;
|
|
85
|
+
/** External editor; when omitted one is created from `options`. */
|
|
86
|
+
editor = null;
|
|
87
|
+
options = null;
|
|
88
|
+
mode = 'default';
|
|
89
|
+
placeholder = '';
|
|
90
|
+
disabled = false;
|
|
91
|
+
readonly = false;
|
|
92
|
+
/** Auto-height ceiling — px number or CSS length; scrolls after the cap. */
|
|
93
|
+
maxHeight = '';
|
|
94
|
+
valueChange = new EventEmitter();
|
|
95
|
+
submitted = new EventEmitter();
|
|
96
|
+
/** Custom toolbar projection (suppresses the default one). */
|
|
97
|
+
customToolbar = null;
|
|
98
|
+
state = signal(null);
|
|
99
|
+
/** Default circular send button for compact/chat/expanded (Copilot style). */
|
|
100
|
+
showDefaultToolbar = computed(() => {
|
|
101
|
+
const current = this.state();
|
|
102
|
+
const mode = current?.mode ?? this.mode;
|
|
103
|
+
return (mode === 'compact' || mode === 'chat' || mode === 'expanded') && !this.customToolbar;
|
|
104
|
+
});
|
|
105
|
+
created = false;
|
|
106
|
+
resolved = null;
|
|
107
|
+
unsubscribe = null;
|
|
108
|
+
constructor(holder) {
|
|
109
|
+
this.holder = holder;
|
|
110
|
+
}
|
|
111
|
+
get editorInstance() {
|
|
112
|
+
if (!this.resolved)
|
|
113
|
+
throw new Error('Editor not initialized');
|
|
114
|
+
return this.resolved;
|
|
115
|
+
}
|
|
116
|
+
ngOnChanges(changes) {
|
|
117
|
+
if (!this.resolved)
|
|
118
|
+
return;
|
|
119
|
+
const patch = {};
|
|
120
|
+
if (changes['mode']?.currentValue)
|
|
121
|
+
patch.mode = changes['mode'].currentValue;
|
|
122
|
+
if (changes['placeholder'])
|
|
123
|
+
patch.placeholder = changes['placeholder'].currentValue;
|
|
124
|
+
if (changes['disabled'])
|
|
125
|
+
patch.disabled = changes['disabled'].currentValue;
|
|
126
|
+
if (changes['readonly'])
|
|
127
|
+
patch.readonly = changes['readonly'].currentValue;
|
|
128
|
+
if (Object.keys(patch).length > 0)
|
|
129
|
+
this.editorInstance.configure(patch);
|
|
130
|
+
}
|
|
131
|
+
ngOnInit() {
|
|
132
|
+
if (this.editor && isAIComposer(this.editor)) {
|
|
133
|
+
this.resolved = this.editor;
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
this.resolved = createAIComposer({ ...(this.options ?? {}) });
|
|
137
|
+
this.created = true;
|
|
138
|
+
}
|
|
139
|
+
this.holder.editor = this.resolved;
|
|
140
|
+
this.editorInstance.configure({
|
|
141
|
+
mode: this.mode,
|
|
142
|
+
placeholder: this.placeholder,
|
|
143
|
+
disabled: this.disabled,
|
|
144
|
+
readonly: this.readonly,
|
|
145
|
+
});
|
|
146
|
+
this.state.set(this.editorInstance.getState());
|
|
147
|
+
this.unsubscribe = this.editorInstance.subscribe((next) => {
|
|
148
|
+
this.state.set(next);
|
|
149
|
+
});
|
|
150
|
+
this.editorInstance.on('change', (event) => this.valueChange.emit(event.value));
|
|
151
|
+
this.editorInstance.on('submit', (event) => this.submitted.emit(event.value));
|
|
152
|
+
}
|
|
153
|
+
ngOnDestroy() {
|
|
154
|
+
this.unsubscribe?.();
|
|
155
|
+
this.unsubscribe = null;
|
|
156
|
+
if (this.created)
|
|
157
|
+
this.resolved?.destroy();
|
|
158
|
+
this.holder.editor = null;
|
|
159
|
+
}
|
|
160
|
+
/** Direct access for template code: {{ editor().serialize('text') }} */
|
|
161
|
+
getEditor() {
|
|
162
|
+
return this.editorInstance;
|
|
163
|
+
}
|
|
164
|
+
// -- ControlValueAccessor ---------------------------------------------------
|
|
165
|
+
writeValue(value) {
|
|
166
|
+
if (value === null || value === undefined)
|
|
167
|
+
return;
|
|
168
|
+
const document = typeof value === 'string' ? value : coerceDocument(value);
|
|
169
|
+
this.editorInstance.setValue(document, { source: 'api' });
|
|
170
|
+
}
|
|
171
|
+
registerOnChange(fn) {
|
|
172
|
+
this.editorInstance.on('change', (event) => fn(event.value));
|
|
173
|
+
}
|
|
174
|
+
registerOnTouched(fn) {
|
|
175
|
+
this.editorInstance.on('blur', () => fn());
|
|
176
|
+
}
|
|
177
|
+
setDisabledState(isDisabled) {
|
|
178
|
+
this.editorInstance.setDisabled(isDisabled);
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
__decorate([
|
|
182
|
+
Input(),
|
|
183
|
+
__metadata("design:type", Object)
|
|
184
|
+
], AIComposerComponent.prototype, "editor", void 0);
|
|
185
|
+
__decorate([
|
|
186
|
+
Input(),
|
|
187
|
+
__metadata("design:type", Object)
|
|
188
|
+
], AIComposerComponent.prototype, "options", void 0);
|
|
189
|
+
__decorate([
|
|
190
|
+
Input(),
|
|
191
|
+
__metadata("design:type", Object)
|
|
192
|
+
], AIComposerComponent.prototype, "mode", void 0);
|
|
193
|
+
__decorate([
|
|
194
|
+
Input(),
|
|
195
|
+
__metadata("design:type", Object)
|
|
196
|
+
], AIComposerComponent.prototype, "placeholder", void 0);
|
|
197
|
+
__decorate([
|
|
198
|
+
Input({ transform: BooleanAttribute }),
|
|
199
|
+
__metadata("design:type", Object)
|
|
200
|
+
], AIComposerComponent.prototype, "disabled", void 0);
|
|
201
|
+
__decorate([
|
|
202
|
+
Input({ transform: BooleanAttribute }),
|
|
203
|
+
__metadata("design:type", Object)
|
|
204
|
+
], AIComposerComponent.prototype, "readonly", void 0);
|
|
205
|
+
__decorate([
|
|
206
|
+
Input(),
|
|
207
|
+
__metadata("design:type", Object)
|
|
208
|
+
], AIComposerComponent.prototype, "maxHeight", void 0);
|
|
209
|
+
__decorate([
|
|
210
|
+
Output(),
|
|
211
|
+
__metadata("design:type", Object)
|
|
212
|
+
], AIComposerComponent.prototype, "valueChange", void 0);
|
|
213
|
+
__decorate([
|
|
214
|
+
Output(),
|
|
215
|
+
__metadata("design:type", Object)
|
|
216
|
+
], AIComposerComponent.prototype, "submitted", void 0);
|
|
217
|
+
__decorate([
|
|
218
|
+
ContentChild(AIComposerToolbarDirective),
|
|
219
|
+
__metadata("design:type", Object)
|
|
220
|
+
], AIComposerComponent.prototype, "customToolbar", void 0);
|
|
221
|
+
AIComposerComponent = __decorate([
|
|
222
|
+
Component({
|
|
223
|
+
selector: 'aic-ai-composer',
|
|
224
|
+
standalone: true,
|
|
225
|
+
imports: [
|
|
226
|
+
forwardRef(() => AIComposerInputComponent),
|
|
227
|
+
forwardRef(() => SubmitButtonComponent),
|
|
228
|
+
],
|
|
229
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
230
|
+
providers: [
|
|
231
|
+
AiComposerEditorHolder,
|
|
232
|
+
{ provide: NG_VALUE_ACCESSOR, multi: true, useExisting: AIComposerComponent },
|
|
233
|
+
],
|
|
234
|
+
template: `
|
|
235
|
+
<ng-content select="[aic-header]" />
|
|
236
|
+
<div class="aic-body" data-aic-slot="body">
|
|
237
|
+
<ng-content select="[aic-attachments]" />
|
|
238
|
+
<div class="aic-input-wrap">
|
|
239
|
+
<aic-ai-composer-input />
|
|
240
|
+
</div>
|
|
241
|
+
</div>
|
|
242
|
+
<ng-content select="[aic-toolbar]" />
|
|
243
|
+
@if (showDefaultToolbar()) {
|
|
244
|
+
<div class="aic-toolbar" data-aic-slot="toolbar">
|
|
245
|
+
<aic-ai-composer-submit />
|
|
246
|
+
</div>
|
|
247
|
+
}
|
|
248
|
+
<ng-content select="[aic-footer]" />
|
|
249
|
+
`,
|
|
250
|
+
host: {
|
|
251
|
+
class: 'aic-root',
|
|
252
|
+
'[attr.data-aic-mode]': 'state()?.mode ?? mode',
|
|
253
|
+
'[style.--aic-input-max-height]': "maxHeight === '' ? null : (typeof maxHeight === 'number' ? maxHeight + 'px' : maxHeight)",
|
|
254
|
+
},
|
|
255
|
+
}),
|
|
256
|
+
__param(0, Inject(AiComposerEditorHolder)),
|
|
257
|
+
__metadata("design:paramtypes", [AiComposerEditorHolder])
|
|
258
|
+
], AIComposerComponent);
|
|
259
|
+
export { AIComposerComponent };
|
|
260
|
+
// Minimal boolean attribute transform (standalone, Angular 16+ compatible)
|
|
261
|
+
function BooleanAttribute(value) {
|
|
262
|
+
return value === '' || value === true;
|
|
263
|
+
}
|
|
264
|
+
// ---------------------------------------------------------------------------
|
|
265
|
+
// Input surface
|
|
266
|
+
// ---------------------------------------------------------------------------
|
|
267
|
+
let AIComposerInputComponent = class AIComposerInputComponent {
|
|
268
|
+
elementRef;
|
|
269
|
+
holder = inject(AiComposerEditorHolder, { optional: true });
|
|
270
|
+
surface = null;
|
|
271
|
+
list = null;
|
|
272
|
+
constructor(elementRef) {
|
|
273
|
+
this.elementRef = elementRef;
|
|
274
|
+
}
|
|
275
|
+
ngAfterViewInit() {
|
|
276
|
+
const editor = this.holder?.editor;
|
|
277
|
+
if (!editor)
|
|
278
|
+
return;
|
|
279
|
+
const host = this.elementRef.nativeElement;
|
|
280
|
+
this.surface = createEditableSurface(editor, host);
|
|
281
|
+
this.list = createSuggestionList(editor, undefined, { inputHost: host });
|
|
282
|
+
if (host.parentElement)
|
|
283
|
+
host.parentElement.appendChild(this.list.element);
|
|
284
|
+
}
|
|
285
|
+
ngOnDestroy() {
|
|
286
|
+
this.list?.destroy();
|
|
287
|
+
this.surface?.destroy();
|
|
288
|
+
this.list = null;
|
|
289
|
+
this.surface = null;
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
AIComposerInputComponent = __decorate([
|
|
293
|
+
Component({
|
|
294
|
+
selector: 'aic-ai-composer-input',
|
|
295
|
+
standalone: true,
|
|
296
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
297
|
+
template: '',
|
|
298
|
+
host: { class: 'aic-input-host', 'data-aic-slot': 'input' },
|
|
299
|
+
}),
|
|
300
|
+
__metadata("design:paramtypes", [ElementRef])
|
|
301
|
+
], AIComposerInputComponent);
|
|
302
|
+
export { AIComposerInputComponent };
|
|
303
|
+
// ---------------------------------------------------------------------------
|
|
304
|
+
// Default actions
|
|
305
|
+
// ---------------------------------------------------------------------------
|
|
306
|
+
let SubmitButtonComponent = class SubmitButtonComponent {
|
|
307
|
+
editor = injectAIComposer();
|
|
308
|
+
state = injectAIComposerState();
|
|
309
|
+
canSubmit = computed(() => {
|
|
310
|
+
const state = this.state();
|
|
311
|
+
if (!state)
|
|
312
|
+
return false;
|
|
313
|
+
return !state.disabled && !state.readonly && (!state.empty || state.attachments.length > 0);
|
|
314
|
+
});
|
|
315
|
+
submit() {
|
|
316
|
+
void this.editor.submit();
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
SubmitButtonComponent = __decorate([
|
|
320
|
+
Component({
|
|
321
|
+
selector: 'aic-ai-composer-submit',
|
|
322
|
+
standalone: true,
|
|
323
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
324
|
+
template: `<button
|
|
325
|
+
type="button"
|
|
326
|
+
class="aic-toolbar-submit"
|
|
327
|
+
data-aic-action="submit"
|
|
328
|
+
aria-label="Send"
|
|
329
|
+
[disabled]="!canSubmit()"
|
|
330
|
+
(click)="submit()"
|
|
331
|
+
>
|
|
332
|
+
@if (state()?.submitting) {
|
|
333
|
+
<span class="aic-spinner" aria-hidden="true"></span>
|
|
334
|
+
} @else {
|
|
335
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
|
336
|
+
stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
337
|
+
<path d="M12 19V5" /><path d="m5 12 7-7 7 7" />
|
|
338
|
+
</svg>
|
|
339
|
+
}
|
|
340
|
+
</button>`,
|
|
341
|
+
})
|
|
342
|
+
], SubmitButtonComponent);
|
|
343
|
+
export { SubmitButtonComponent };
|
|
344
|
+
/** Convenience import collection. */
|
|
345
|
+
export const AI_COMPOSER_IMPORTS = [
|
|
346
|
+
AIComposerComponent,
|
|
347
|
+
AIComposerInputComponent,
|
|
348
|
+
SubmitButtonComponent,
|
|
349
|
+
AIComposerHeaderDirective,
|
|
350
|
+
AIComposerToolbarDirective,
|
|
351
|
+
AIComposerFooterDirective,
|
|
352
|
+
AIComposerAttachmentsDirective,
|
|
353
|
+
];
|
|
354
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ai-composer/angular",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/index.js",
|
|
9
|
+
"dist/index.d.ts"
|
|
10
|
+
],
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./package.json": "./package.json"
|
|
19
|
+
},
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"@ai-composer/core": "^0.1.0",
|
|
22
|
+
"@ai-composer/dom": "^0.1.0",
|
|
23
|
+
"@angular/core": ">=16.0.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@angular/core": "^19.0.0",
|
|
27
|
+
"rxjs": "^7.8.1",
|
|
28
|
+
"vitest": "^2.1.8",
|
|
29
|
+
"jsdom": "^25.0.1",
|
|
30
|
+
"@ai-composer/core": "0.1.0",
|
|
31
|
+
"@ai-composer/dom": "0.1.0"
|
|
32
|
+
}
|
|
33
|
+
}
|