@copilotkitnext/angular 0.0.1
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/.turbo/turbo-build.log +39 -0
- package/.turbo/turbo-check-types.log +0 -0
- package/.turbo/turbo-test.log +71 -0
- package/LICENSE +10 -0
- package/README-agent-context.md +310 -0
- package/dist/LICENSE +10 -0
- package/dist/components/chat/copilot-chat-assistant-message-buttons.component.d.ts +75 -0
- package/dist/components/chat/copilot-chat-assistant-message-renderer.component.d.ts +31 -0
- package/dist/components/chat/copilot-chat-assistant-message-toolbar.component.d.ts +8 -0
- package/dist/components/chat/copilot-chat-assistant-message.component.d.ts +131 -0
- package/dist/components/chat/copilot-chat-assistant-message.types.d.ts +31 -0
- package/dist/components/chat/copilot-chat-audio-recorder.component.d.ts +40 -0
- package/dist/components/chat/copilot-chat-buttons.component.d.ts +66 -0
- package/dist/components/chat/copilot-chat-input-defaults.d.ts +37 -0
- package/dist/components/chat/copilot-chat-input.component.d.ts +133 -0
- package/dist/components/chat/copilot-chat-input.types.d.ts +129 -0
- package/dist/components/chat/copilot-chat-message-view-cursor.component.d.ts +15 -0
- package/dist/components/chat/copilot-chat-message-view.component.d.ts +293 -0
- package/dist/components/chat/copilot-chat-message-view.types.d.ts +24 -0
- package/dist/components/chat/copilot-chat-textarea.component.d.ts +45 -0
- package/dist/components/chat/copilot-chat-tool-calls-view.component.d.ts +35 -0
- package/dist/components/chat/copilot-chat-toolbar.component.d.ts +8 -0
- package/dist/components/chat/copilot-chat-tools-menu.component.d.ts +20 -0
- package/dist/components/chat/copilot-chat-user-message-branch-navigation.component.d.ts +23 -0
- package/dist/components/chat/copilot-chat-user-message-buttons.component.d.ts +39 -0
- package/dist/components/chat/copilot-chat-user-message-renderer.component.d.ts +9 -0
- package/dist/components/chat/copilot-chat-user-message-toolbar.component.d.ts +8 -0
- package/dist/components/chat/copilot-chat-user-message.component.d.ts +55 -0
- package/dist/components/chat/copilot-chat-user-message.types.d.ts +33 -0
- package/dist/components/chat/copilot-chat-view-disclaimer.component.d.ts +15 -0
- package/dist/components/chat/copilot-chat-view-feather.component.d.ts +15 -0
- package/dist/components/chat/copilot-chat-view-handlers.service.d.ts +11 -0
- package/dist/components/chat/copilot-chat-view-input-container.component.d.ts +23 -0
- package/dist/components/chat/copilot-chat-view-scroll-to-bottom-button.component.d.ts +17 -0
- package/dist/components/chat/copilot-chat-view-scroll-view.component.d.ts +84 -0
- package/dist/components/chat/copilot-chat-view.component.d.ts +205 -0
- package/dist/components/chat/copilot-chat-view.types.d.ts +42 -0
- package/dist/components/chat/copilot-chat.component.d.ts +37 -0
- package/dist/components/copilotkit-tool-render.component.d.ts +25 -0
- package/dist/core/chat-configuration/chat-configuration.providers.d.ts +54 -0
- package/dist/core/chat-configuration/chat-configuration.service.d.ts +75 -0
- package/dist/core/chat-configuration/chat-configuration.types.d.ts +27 -0
- package/dist/core/copilotkit.providers.d.ts +13 -0
- package/dist/core/copilotkit.service.d.ts +119 -0
- package/dist/core/copilotkit.types.d.ts +83 -0
- package/dist/directives/copilotkit-agent-context.directive.d.ts +68 -0
- package/dist/directives/copilotkit-agent.directive.d.ts +106 -0
- package/dist/directives/copilotkit-chat-config.directive.d.ts +84 -0
- package/dist/directives/copilotkit-config.directive.d.ts +44 -0
- package/dist/directives/copilotkit-frontend-tool.directive.d.ts +25 -0
- package/dist/directives/copilotkit-human-in-the-loop.directive.d.ts +124 -0
- package/dist/directives/stick-to-bottom.directive.d.ts +62 -0
- package/dist/fesm2022/copilotkitnext-angular.mjs +9314 -0
- package/dist/fesm2022/copilotkitnext-angular.mjs.map +1 -0
- package/dist/index.d.ts +55 -0
- package/dist/lib/directives/tooltip.directive.d.ts +33 -0
- package/dist/lib/slots/copilot-slot.component.d.ts +34 -0
- package/dist/lib/slots/slot.types.d.ts +55 -0
- package/dist/lib/slots/slot.utils.d.ts +108 -0
- package/dist/lib/utils.d.ts +6 -0
- package/dist/services/resize-observer.service.d.ts +44 -0
- package/dist/services/scroll-position.service.d.ts +50 -0
- package/dist/styles.css +1963 -0
- package/dist/types/frontend-tool.d.ts +37 -0
- package/dist/types/human-in-the-loop.d.ts +44 -0
- package/dist/utils/agent-context.utils.d.ts +75 -0
- package/dist/utils/agent.utils.d.ts +99 -0
- package/dist/utils/chat-config.utils.d.ts +166 -0
- package/dist/utils/copilotkit.utils.d.ts +16 -0
- package/dist/utils/frontend-tool.utils.d.ts +119 -0
- package/dist/utils/human-in-the-loop.utils.d.ts +92 -0
- package/eslint.config.mjs +20 -0
- package/ng-package.json +19 -0
- package/package.json +96 -0
- package/slots.md +331 -0
- package/src/components/chat/__tests__/copilot-chat-assistant-message.component.spec.ts +282 -0
- package/src/components/chat/__tests__/copilot-chat-input.component.spec.ts +419 -0
- package/src/components/chat/__tests__/copilot-chat-message-view.component.spec.ts +372 -0
- package/src/components/chat/__tests__/copilot-chat-user-message.component.spec.ts +249 -0
- package/src/components/chat/copilot-chat-assistant-message-buttons.component.ts +292 -0
- package/src/components/chat/copilot-chat-assistant-message-renderer.component.ts +472 -0
- package/src/components/chat/copilot-chat-assistant-message-toolbar.component.ts +29 -0
- package/src/components/chat/copilot-chat-assistant-message.component.ts +463 -0
- package/src/components/chat/copilot-chat-assistant-message.types.ts +50 -0
- package/src/components/chat/copilot-chat-audio-recorder.component.ts +241 -0
- package/src/components/chat/copilot-chat-buttons.component.ts +308 -0
- package/src/components/chat/copilot-chat-buttons.component.ts.bak +471 -0
- package/src/components/chat/copilot-chat-input-defaults.ts +47 -0
- package/src/components/chat/copilot-chat-input.component.ts +512 -0
- package/src/components/chat/copilot-chat-input.types.ts +148 -0
- package/src/components/chat/copilot-chat-message-view-cursor.component.ts +51 -0
- package/src/components/chat/copilot-chat-message-view.component.ts +233 -0
- package/src/components/chat/copilot-chat-message-view.types.ts +39 -0
- package/src/components/chat/copilot-chat-textarea.component.ts +220 -0
- package/src/components/chat/copilot-chat-tool-calls-view.component.ts +261 -0
- package/src/components/chat/copilot-chat-toolbar.component.ts +35 -0
- package/src/components/chat/copilot-chat-tools-menu.component.ts +185 -0
- package/src/components/chat/copilot-chat-user-message-branch-navigation.component.ts +121 -0
- package/src/components/chat/copilot-chat-user-message-buttons.component.ts +170 -0
- package/src/components/chat/copilot-chat-user-message-renderer.component.ts +37 -0
- package/src/components/chat/copilot-chat-user-message-toolbar.component.ts +37 -0
- package/src/components/chat/copilot-chat-user-message.component.ts +247 -0
- package/src/components/chat/copilot-chat-user-message.types.ts +42 -0
- package/src/components/chat/copilot-chat-view-disclaimer.component.ts +51 -0
- package/src/components/chat/copilot-chat-view-feather.component.ts +47 -0
- package/src/components/chat/copilot-chat-view-handlers.service.ts +14 -0
- package/src/components/chat/copilot-chat-view-input-container.component.ts +87 -0
- package/src/components/chat/copilot-chat-view-scroll-to-bottom-button.component.ts +79 -0
- package/src/components/chat/copilot-chat-view-scroll-view.component.ts +322 -0
- package/src/components/chat/copilot-chat-view.component.ts +420 -0
- package/src/components/chat/copilot-chat-view.types.ts +52 -0
- package/src/components/chat/copilot-chat.component.ts +232 -0
- package/src/components/copilotkit-tool-render.component.ts +169 -0
- package/src/core/__tests__/copilotkit.service.spec.ts +1051 -0
- package/src/core/__tests__/copilotkit.service.wildcard.spec.ts +316 -0
- package/src/core/chat-configuration/__tests__/chat-configuration.service.spec.ts +287 -0
- package/src/core/chat-configuration/chat-configuration.providers.ts +71 -0
- package/src/core/chat-configuration/chat-configuration.service.ts +162 -0
- package/src/core/chat-configuration/chat-configuration.types.ts +57 -0
- package/src/core/copilotkit.providers.ts +59 -0
- package/src/core/copilotkit.service.ts +542 -0
- package/src/core/copilotkit.types.ts +132 -0
- package/src/directives/__tests__/copilotkit-agent-context.directive.spec.ts +384 -0
- package/src/directives/__tests__/copilotkit-agent.directive.spec.ts +253 -0
- package/src/directives/__tests__/copilotkit-chat-config.directive.spec.ts +385 -0
- package/src/directives/__tests__/copilotkit-config.directive.spec.ts +69 -0
- package/src/directives/__tests__/copilotkit-frontend-tool-simple.directive.spec.ts +60 -0
- package/src/directives/__tests__/copilotkit-frontend-tool.directive.spec.ts +108 -0
- package/src/directives/__tests__/copilotkit-human-in-the-loop.directive.spec.ts +452 -0
- package/src/directives/copilotkit-agent-context.directive.ts +138 -0
- package/src/directives/copilotkit-agent.directive.ts +225 -0
- package/src/directives/copilotkit-chat-config.directive.ts +241 -0
- package/src/directives/copilotkit-config.directive.ts +81 -0
- package/src/directives/copilotkit-frontend-tool.directive.ts +145 -0
- package/src/directives/copilotkit-human-in-the-loop.directive.ts +281 -0
- package/src/directives/stick-to-bottom.directive.ts +204 -0
- package/src/index.ts +105 -0
- package/src/lib/directives/tooltip.directive.ts +292 -0
- package/src/lib/slots/__tests__/slot.utils.spec.ts +377 -0
- package/src/lib/slots/copilot-slot.component.ts +135 -0
- package/src/lib/slots/index.ts +3 -0
- package/src/lib/slots/slot.types.ts +64 -0
- package/src/lib/slots/slot.utils.ts +289 -0
- package/src/lib/utils.ts +10 -0
- package/src/public-api.ts +1 -0
- package/src/services/resize-observer.service.ts +181 -0
- package/src/services/scroll-position.service.ts +169 -0
- package/src/styles/globals.css +266 -0
- package/src/styles/index.css +3 -0
- package/src/test-setup.ts +15 -0
- package/src/testing/index.ts +3 -0
- package/src/testing/testing.utils.ts +248 -0
- package/src/types/frontend-tool.ts +44 -0
- package/src/types/human-in-the-loop.ts +52 -0
- package/src/utils/__tests__/agent.utils.spec.ts +234 -0
- package/src/utils/__tests__/chat-config.utils.spec.ts +306 -0
- package/src/utils/__tests__/frontend-tool-inject.spec.ts +350 -0
- package/src/utils/__tests__/frontend-tool-integration.spec.ts +199 -0
- package/src/utils/__tests__/frontend-tool.utils.spec.ts +272 -0
- package/src/utils/__tests__/human-in-the-loop.utils.spec.ts +365 -0
- package/src/utils/agent-context.utils.ts +133 -0
- package/src/utils/agent.utils.ts +239 -0
- package/src/utils/chat-config.utils.ts +221 -0
- package/src/utils/copilotkit.utils.ts +20 -0
- package/src/utils/frontend-tool.utils.ts +266 -0
- package/src/utils/human-in-the-loop.utils.ts +359 -0
- package/tsconfig.json +33 -0
- package/tsconfig.spec.json +12 -0
- package/vitest.config.mts +34 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export * from "./core/copilotkit.service";
|
|
2
|
+
export * from "./core/copilotkit.types";
|
|
3
|
+
export * from "./core/copilotkit.providers";
|
|
4
|
+
export type { Message, ToolCall, ToolMessage } from "@ag-ui/core";
|
|
5
|
+
export * from "./core/chat-configuration/chat-configuration.types";
|
|
6
|
+
export * from "./core/chat-configuration/chat-configuration.service";
|
|
7
|
+
export * from "./core/chat-configuration/chat-configuration.providers";
|
|
8
|
+
export * from "./utils/copilotkit.utils";
|
|
9
|
+
export * from "./utils/agent-context.utils";
|
|
10
|
+
export * from "./utils/frontend-tool.utils";
|
|
11
|
+
export { watchAgent, getAgent, subscribeToAgent, registerAgentWatcher, } from "./utils/agent.utils";
|
|
12
|
+
export * from "./utils/human-in-the-loop.utils";
|
|
13
|
+
export * from "./utils/chat-config.utils";
|
|
14
|
+
export { CopilotTooltipDirective } from "./lib/directives/tooltip.directive";
|
|
15
|
+
export { CopilotKitConfigDirective } from "./directives/copilotkit-config.directive";
|
|
16
|
+
export { CopilotKitAgentContextDirective } from "./directives/copilotkit-agent-context.directive";
|
|
17
|
+
export { CopilotKitFrontendToolDirective } from "./directives/copilotkit-frontend-tool.directive";
|
|
18
|
+
export { CopilotKitAgentDirective } from "./directives/copilotkit-agent.directive";
|
|
19
|
+
export { CopilotKitHumanInTheLoopDirective, CopilotKitHumanInTheLoopRespondDirective, } from "./directives/copilotkit-human-in-the-loop.directive";
|
|
20
|
+
export { CopilotKitChatConfigDirective } from "./directives/copilotkit-chat-config.directive";
|
|
21
|
+
export { CopilotKitToolRenderComponent } from "./components/copilotkit-tool-render.component";
|
|
22
|
+
export * from "./components/chat/copilot-chat-input.types";
|
|
23
|
+
export { CopilotChatInputComponent } from "./components/chat/copilot-chat-input.component";
|
|
24
|
+
export { CopilotChatInputDefaults } from "./components/chat/copilot-chat-input-defaults";
|
|
25
|
+
export { CopilotChatTextareaComponent } from "./components/chat/copilot-chat-textarea.component";
|
|
26
|
+
export { CopilotChatAudioRecorderComponent } from "./components/chat/copilot-chat-audio-recorder.component";
|
|
27
|
+
export { CopilotChatSendButtonComponent, CopilotChatToolbarButtonComponent, CopilotChatStartTranscribeButtonComponent, CopilotChatCancelTranscribeButtonComponent, CopilotChatFinishTranscribeButtonComponent, CopilotChatAddFileButtonComponent, } from "./components/chat/copilot-chat-buttons.component";
|
|
28
|
+
export { CopilotChatToolbarComponent } from "./components/chat/copilot-chat-toolbar.component";
|
|
29
|
+
export { CopilotChatToolsMenuComponent } from "./components/chat/copilot-chat-tools-menu.component";
|
|
30
|
+
export * from "./components/chat/copilot-chat-user-message.types";
|
|
31
|
+
export { CopilotChatUserMessageComponent } from "./components/chat/copilot-chat-user-message.component";
|
|
32
|
+
export { CopilotChatUserMessageRendererComponent } from "./components/chat/copilot-chat-user-message-renderer.component";
|
|
33
|
+
export { CopilotChatUserMessageToolbarButtonComponent, CopilotChatUserMessageCopyButtonComponent, CopilotChatUserMessageEditButtonComponent, } from "./components/chat/copilot-chat-user-message-buttons.component";
|
|
34
|
+
export { CopilotChatUserMessageToolbarComponent } from "./components/chat/copilot-chat-user-message-toolbar.component";
|
|
35
|
+
export { CopilotChatUserMessageBranchNavigationComponent } from "./components/chat/copilot-chat-user-message-branch-navigation.component";
|
|
36
|
+
export * from "./components/chat/copilot-chat-assistant-message.types";
|
|
37
|
+
export { CopilotChatAssistantMessageComponent } from "./components/chat/copilot-chat-assistant-message.component";
|
|
38
|
+
export { CopilotChatAssistantMessageRendererComponent } from "./components/chat/copilot-chat-assistant-message-renderer.component";
|
|
39
|
+
export { CopilotChatAssistantMessageToolbarButtonComponent, CopilotChatAssistantMessageCopyButtonComponent, CopilotChatAssistantMessageThumbsUpButtonComponent, CopilotChatAssistantMessageThumbsDownButtonComponent, CopilotChatAssistantMessageReadAloudButtonComponent, CopilotChatAssistantMessageRegenerateButtonComponent, } from "./components/chat/copilot-chat-assistant-message-buttons.component";
|
|
40
|
+
export { CopilotChatAssistantMessageToolbarComponent } from "./components/chat/copilot-chat-assistant-message-toolbar.component";
|
|
41
|
+
export * from "./components/chat/copilot-chat-message-view.types";
|
|
42
|
+
export { CopilotChatMessageViewComponent } from "./components/chat/copilot-chat-message-view.component";
|
|
43
|
+
export { CopilotChatMessageViewCursorComponent } from "./components/chat/copilot-chat-message-view-cursor.component";
|
|
44
|
+
export { CopilotChatToolCallsViewComponent } from "./components/chat/copilot-chat-tool-calls-view.component";
|
|
45
|
+
export * from "./components/chat/copilot-chat-view.types";
|
|
46
|
+
export { CopilotChatViewComponent } from "./components/chat/copilot-chat-view.component";
|
|
47
|
+
export { CopilotChatViewScrollViewComponent } from "./components/chat/copilot-chat-view-scroll-view.component";
|
|
48
|
+
export { CopilotChatViewScrollToBottomButtonComponent } from "./components/chat/copilot-chat-view-scroll-to-bottom-button.component";
|
|
49
|
+
export { CopilotChatViewFeatherComponent } from "./components/chat/copilot-chat-view-feather.component";
|
|
50
|
+
export { CopilotChatViewInputContainerComponent } from "./components/chat/copilot-chat-view-input-container.component";
|
|
51
|
+
export { CopilotChatViewDisclaimerComponent } from "./components/chat/copilot-chat-view-disclaimer.component";
|
|
52
|
+
export { CopilotChatComponent } from "./components/chat/copilot-chat.component";
|
|
53
|
+
export { ScrollPositionService } from "./services/scroll-position.service";
|
|
54
|
+
export { ResizeObserverService } from "./services/resize-observer.service";
|
|
55
|
+
export { StickToBottomDirective } from "./directives/stick-to-bottom.directive";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { OnDestroy } from '@angular/core';
|
|
2
|
+
import { ChangeDetectorRef } from '@angular/core';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export declare class TooltipContentComponent {
|
|
5
|
+
private cdr;
|
|
6
|
+
text: string;
|
|
7
|
+
private _position;
|
|
8
|
+
get position(): 'above' | 'below' | 'left' | 'right';
|
|
9
|
+
set position(value: 'above' | 'below' | 'left' | 'right');
|
|
10
|
+
constructor(cdr: ChangeDetectorRef);
|
|
11
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TooltipContentComponent, never>;
|
|
12
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<TooltipContentComponent, "copilot-tooltip-content", never, {}, {}, never, never, true, never>;
|
|
13
|
+
}
|
|
14
|
+
export declare class CopilotTooltipDirective implements OnDestroy {
|
|
15
|
+
tooltipText: string;
|
|
16
|
+
tooltipPosition: 'above' | 'below' | 'left' | 'right';
|
|
17
|
+
tooltipDelay: number;
|
|
18
|
+
private overlay;
|
|
19
|
+
private overlayPositionBuilder;
|
|
20
|
+
private elementRef;
|
|
21
|
+
private viewContainerRef;
|
|
22
|
+
private overlayRef?;
|
|
23
|
+
private tooltipTimeout?;
|
|
24
|
+
private originalTitle?;
|
|
25
|
+
onMouseEnter(): void;
|
|
26
|
+
onMouseLeave(): void;
|
|
27
|
+
private show;
|
|
28
|
+
private hide;
|
|
29
|
+
private getPositions;
|
|
30
|
+
ngOnDestroy(): void;
|
|
31
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CopilotTooltipDirective, never>;
|
|
32
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<CopilotTooltipDirective, "[copilotTooltip]", never, { "tooltipText": { "alias": "copilotTooltip"; "required": false; }; "tooltipPosition": { "alias": "tooltipPosition"; "required": false; }; "tooltipDelay": { "alias": "tooltipDelay"; "required": false; }; }, {}, never, never, true, never>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { TemplateRef, ViewContainerRef, OnInit, OnChanges, SimpleChanges, ChangeDetectorRef } from '@angular/core';
|
|
2
|
+
import { Type } from '@angular/core';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* @internal - This component is for internal use only.
|
|
6
|
+
* Simple slot component for rendering custom content or defaults.
|
|
7
|
+
* Supports templates and components only.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```html
|
|
11
|
+
* <!-- With template -->
|
|
12
|
+
* <copilot-slot [slot]="sendButtonTemplate" [context]="buttonContext">
|
|
13
|
+
* <button class="default-btn">Default</button>
|
|
14
|
+
* </copilot-slot>
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare class CopilotSlotComponent implements OnInit, OnChanges {
|
|
18
|
+
private viewContainer;
|
|
19
|
+
private cdr;
|
|
20
|
+
slot?: TemplateRef<any> | Type<any>;
|
|
21
|
+
context?: any;
|
|
22
|
+
defaultComponent?: Type<any>;
|
|
23
|
+
outputs?: Record<string, (event: any) => void>;
|
|
24
|
+
private slotContainer;
|
|
25
|
+
private componentRef?;
|
|
26
|
+
constructor(viewContainer: ViewContainerRef, cdr: ChangeDetectorRef);
|
|
27
|
+
ngOnInit(): void;
|
|
28
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
29
|
+
isTemplate(value: any): value is TemplateRef<any>;
|
|
30
|
+
private renderSlot;
|
|
31
|
+
private updateComponentProps;
|
|
32
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CopilotSlotComponent, never>;
|
|
33
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<CopilotSlotComponent, "copilot-slot", never, { "slot": { "alias": "slot"; "required": false; }; "context": { "alias": "context"; "required": false; }; "defaultComponent": { "alias": "defaultComponent"; "required": false; }; "outputs": { "alias": "outputs"; "required": false; }; }, {}, never, ["*"], true, never>;
|
|
34
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Type, TemplateRef, InjectionToken } from '@angular/core';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a value that can be used as a slot override.
|
|
4
|
+
* Can be a component type or template reference only.
|
|
5
|
+
* @internal - This type is for internal use only
|
|
6
|
+
*/
|
|
7
|
+
export type SlotValue<T = any> = Type<T> | TemplateRef<T>;
|
|
8
|
+
/**
|
|
9
|
+
* Configuration for a slot
|
|
10
|
+
* @internal - This interface is for internal use only
|
|
11
|
+
*/
|
|
12
|
+
export interface SlotConfig<T = any> {
|
|
13
|
+
value?: SlotValue<T>;
|
|
14
|
+
default?: Type<T>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Context passed to slot templates
|
|
18
|
+
*/
|
|
19
|
+
export interface SlotContext<T = any> {
|
|
20
|
+
$implicit: T;
|
|
21
|
+
props?: Partial<T>;
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Slot registry entry
|
|
26
|
+
* @internal - This interface is for internal use only
|
|
27
|
+
*/
|
|
28
|
+
export interface SlotRegistryEntry<T = any> {
|
|
29
|
+
component?: Type<T>;
|
|
30
|
+
template?: TemplateRef<T>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Options for rendering a slot
|
|
34
|
+
*/
|
|
35
|
+
export interface RenderSlotOptions<T = any> {
|
|
36
|
+
slot?: SlotValue<T>;
|
|
37
|
+
defaultComponent: Type<T>;
|
|
38
|
+
props?: Partial<T>;
|
|
39
|
+
injector?: any;
|
|
40
|
+
outputs?: Record<string, (event: any) => void>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Injection token for slot configuration
|
|
44
|
+
*/
|
|
45
|
+
export declare const SLOT_CONFIG: InjectionToken<ReadonlyMap<string, SlotRegistryEntry<any>>>;
|
|
46
|
+
/**
|
|
47
|
+
* Type for components with slots
|
|
48
|
+
*/
|
|
49
|
+
export type WithSlots<S extends Record<string, Type<any>>, Rest = object> = {
|
|
50
|
+
[K in keyof S as `${string & K}Component`]?: Type<any>;
|
|
51
|
+
} & {
|
|
52
|
+
[K in keyof S as `${string & K}Template`]?: TemplateRef<any>;
|
|
53
|
+
} & {
|
|
54
|
+
[K in keyof S as `${string & K}Class`]?: string;
|
|
55
|
+
} & Rest;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { Type, ViewContainerRef, ComponentRef, EmbeddedViewRef } from '@angular/core';
|
|
2
|
+
import { SlotValue, RenderSlotOptions, SlotRegistryEntry } from './slot.types';
|
|
3
|
+
/**
|
|
4
|
+
* Renders a slot value into a ViewContainerRef.
|
|
5
|
+
* This is the core utility for slot rendering.
|
|
6
|
+
*
|
|
7
|
+
* @param viewContainer - The ViewContainerRef to render into
|
|
8
|
+
* @param options - Options for rendering the slot
|
|
9
|
+
* @returns The created component or embedded view reference
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* export class MyComponent {
|
|
14
|
+
* @ViewChild('container', { read: ViewContainerRef }) container!: ViewContainerRef;
|
|
15
|
+
*
|
|
16
|
+
* renderButton() {
|
|
17
|
+
* renderSlot(this.container, {
|
|
18
|
+
* slot: this.buttonOverride,
|
|
19
|
+
* defaultComponent: DefaultButton,
|
|
20
|
+
* props: { text: 'Click me' },
|
|
21
|
+
* outputs: { click: (event) => this.handleClick(event) }
|
|
22
|
+
* });
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function renderSlot<T = any>(viewContainer: ViewContainerRef, options: RenderSlotOptions<T>): ComponentRef<T> | EmbeddedViewRef<T> | null;
|
|
28
|
+
/**
|
|
29
|
+
* Checks if a value is a component type.
|
|
30
|
+
* Simplified check - rely on try/catch for actual validation.
|
|
31
|
+
*/
|
|
32
|
+
export declare function isComponentType(value: any): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Checks if a value is a valid slot value.
|
|
35
|
+
*/
|
|
36
|
+
export declare function isSlotValue(value: any): value is SlotValue;
|
|
37
|
+
/**
|
|
38
|
+
* Normalizes a slot value to a consistent format.
|
|
39
|
+
*/
|
|
40
|
+
export declare function normalizeSlotValue<T = any>(value: SlotValue<T> | undefined, defaultComponent: Type<T> | undefined): SlotRegistryEntry<T>;
|
|
41
|
+
/**
|
|
42
|
+
* Creates a slot configuration map for a component.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const slots = createSlotConfig({
|
|
47
|
+
* sendButton: CustomSendButton,
|
|
48
|
+
* toolbar: 'custom-toolbar-class',
|
|
49
|
+
* footer: footerTemplate
|
|
50
|
+
* }, {
|
|
51
|
+
* sendButton: DefaultSendButton,
|
|
52
|
+
* toolbar: DefaultToolbar,
|
|
53
|
+
* footer: DefaultFooter
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function createSlotConfig<T extends Record<string, Type<any>>>(overrides: Partial<Record<keyof T, SlotValue>>, defaults: T): Map<keyof T, SlotRegistryEntry>;
|
|
58
|
+
/**
|
|
59
|
+
* Provides slot configuration to child components via DI.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* @Component({
|
|
64
|
+
* providers: [
|
|
65
|
+
* provideSlots({
|
|
66
|
+
* sendButton: CustomSendButton,
|
|
67
|
+
* toolbar: CustomToolbar
|
|
68
|
+
* })
|
|
69
|
+
* ]
|
|
70
|
+
* })
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare function provideSlots(slots: Record<string, Type<any>>): {
|
|
74
|
+
provide: import("@angular/core").InjectionToken<ReadonlyMap<string, SlotRegistryEntry<any>>>;
|
|
75
|
+
useValue: Map<string, SlotRegistryEntry<any>>;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Gets slot configuration from DI.
|
|
79
|
+
* Must be called within an injection context.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* export class MyComponent {
|
|
84
|
+
* slots = getSlotConfig();
|
|
85
|
+
*
|
|
86
|
+
* ngOnInit() {
|
|
87
|
+
* const sendButton = this.slots?.get('sendButton');
|
|
88
|
+
* }
|
|
89
|
+
* }
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
export declare function getSlotConfig(): ReadonlyMap<string, SlotRegistryEntry> | null;
|
|
93
|
+
/**
|
|
94
|
+
* Creates a render function for a specific slot.
|
|
95
|
+
* Useful for creating reusable slot renderers.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* const renderSendButton = createSlotRenderer(
|
|
100
|
+
* DefaultSendButton,
|
|
101
|
+
* 'sendButton'
|
|
102
|
+
* );
|
|
103
|
+
*
|
|
104
|
+
* // Later in template
|
|
105
|
+
* renderSendButton(this.viewContainer, this.sendButtonOverride);
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
export declare function createSlotRenderer<T>(defaultComponent: Type<T>, slotName?: string): (viewContainer: ViewContainerRef, slot?: SlotValue<T>, props?: Partial<T>, outputs?: Record<string, (event: any) => void>) => ComponentRef<T> | EmbeddedViewRef<T>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ElementRef, NgZone, OnDestroy } from '@angular/core';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export interface ResizeState {
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
isResizing: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare class ResizeObserverService implements OnDestroy {
|
|
10
|
+
private ngZone;
|
|
11
|
+
private destroy$;
|
|
12
|
+
private observers;
|
|
13
|
+
private resizeStates;
|
|
14
|
+
private resizeTimeouts;
|
|
15
|
+
constructor(ngZone: NgZone);
|
|
16
|
+
/**
|
|
17
|
+
* Observe element resize with debouncing and resizing state
|
|
18
|
+
* @param element Element to observe
|
|
19
|
+
* @param debounceMs Debounce time (default 250ms)
|
|
20
|
+
* @param resizingDurationMs How long to show "isResizing" state (default 250ms)
|
|
21
|
+
*/
|
|
22
|
+
observeElement(element: ElementRef<HTMLElement> | HTMLElement, debounceMs?: number, resizingDurationMs?: number): Observable<ResizeState>;
|
|
23
|
+
/**
|
|
24
|
+
* Stop observing an element
|
|
25
|
+
* @param element Element to stop observing
|
|
26
|
+
*/
|
|
27
|
+
unobserve(element: ElementRef<HTMLElement> | HTMLElement): void;
|
|
28
|
+
/**
|
|
29
|
+
* Get current size of element
|
|
30
|
+
* @param element Element to measure
|
|
31
|
+
*/
|
|
32
|
+
getCurrentSize(element: ElementRef<HTMLElement> | HTMLElement): {
|
|
33
|
+
width: number;
|
|
34
|
+
height: number;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Get current resize state of element
|
|
38
|
+
* @param element Element to check
|
|
39
|
+
*/
|
|
40
|
+
getCurrentState(element: ElementRef<HTMLElement> | HTMLElement): ResizeState | null;
|
|
41
|
+
ngOnDestroy(): void;
|
|
42
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ResizeObserverService, never>;
|
|
43
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ResizeObserverService>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ElementRef, NgZone, OnDestroy } from '@angular/core';
|
|
2
|
+
import { ScrollDispatcher, ViewportRuler } from '@angular/cdk/scrolling';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
export interface ScrollState {
|
|
6
|
+
isAtBottom: boolean;
|
|
7
|
+
scrollTop: number;
|
|
8
|
+
scrollHeight: number;
|
|
9
|
+
clientHeight: number;
|
|
10
|
+
}
|
|
11
|
+
export declare class ScrollPositionService implements OnDestroy {
|
|
12
|
+
private scrollDispatcher;
|
|
13
|
+
private viewportRuler;
|
|
14
|
+
private ngZone;
|
|
15
|
+
private destroy$;
|
|
16
|
+
private scrollStateSubject;
|
|
17
|
+
scrollState$: Observable<ScrollState>;
|
|
18
|
+
constructor(scrollDispatcher: ScrollDispatcher, viewportRuler: ViewportRuler, ngZone: NgZone);
|
|
19
|
+
/**
|
|
20
|
+
* Monitor scroll position of an element
|
|
21
|
+
* @param element The element to monitor
|
|
22
|
+
* @param threshold Pixels from bottom to consider "at bottom" (default 10)
|
|
23
|
+
*/
|
|
24
|
+
monitorScrollPosition(element: ElementRef<HTMLElement> | HTMLElement, threshold?: number): Observable<ScrollState>;
|
|
25
|
+
/**
|
|
26
|
+
* Scroll element to bottom with smooth animation
|
|
27
|
+
* @param element The element to scroll
|
|
28
|
+
* @param smooth Whether to use smooth scrolling
|
|
29
|
+
*/
|
|
30
|
+
scrollToBottom(element: ElementRef<HTMLElement> | HTMLElement, smooth?: boolean): void;
|
|
31
|
+
/**
|
|
32
|
+
* Check if element is at bottom
|
|
33
|
+
* @param element The element to check
|
|
34
|
+
* @param threshold Pixels from bottom to consider "at bottom"
|
|
35
|
+
*/
|
|
36
|
+
isAtBottom(element: ElementRef<HTMLElement> | HTMLElement, threshold?: number): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Get current scroll state of element
|
|
39
|
+
*/
|
|
40
|
+
getScrollState(element: HTMLElement, threshold: number): ScrollState;
|
|
41
|
+
/**
|
|
42
|
+
* Create a ResizeObserver for element size changes
|
|
43
|
+
* @param element The element to observe
|
|
44
|
+
* @param debounceMs Debounce time in milliseconds
|
|
45
|
+
*/
|
|
46
|
+
observeResize(element: ElementRef<HTMLElement> | HTMLElement, debounceMs?: number): Observable<ResizeObserverEntry>;
|
|
47
|
+
ngOnDestroy(): void;
|
|
48
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ScrollPositionService, never>;
|
|
49
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ScrollPositionService>;
|
|
50
|
+
}
|