ng-primitives 0.78.0 → 0.80.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/ai/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # ng-primitives/ai
2
+
3
+ Secondary entry point of `ng-primitives`. It can be used by importing from `ng-primitives/ai`.
package/ai/index.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ export { NgpPromptComposerInput } from './prompt-composer-input/prompt-composer-input';
2
+ export { NgpPromptComposerSubmit } from './prompt-composer-submit/prompt-composer-submit';
3
+ export { NgpPromptComposer } from './prompt-composer/prompt-composer';
4
+ export { NgpThreadMessage } from './thread-message/thread-message';
5
+ export { NgpThread } from './thread/thread';
6
+ export { NgpPromptComposerDictation } from './prompt-composer-dictation/prompt-composer-dictation';
7
+ export { NgpThreadViewport } from './thread-viewport/thread-viewport';
8
+ export { NgpThreadSuggestion } from './thread-suggestion/thread-suggestion';
9
+ export { providePromptComposerState, injectPromptComposerState, } from './prompt-composer/prompt-composer-state';
10
+ export { providePromptComposerDictationState, injectPromptComposerDictationState, } from './prompt-composer-dictation/prompt-composer-dictation-state';
11
+ export { providePromptComposerInputState, injectPromptComposerInputState, } from './prompt-composer-input/prompt-composer-input-state';
12
+ export { providePromptComposerSubmitState, injectPromptComposerSubmitState, } from './prompt-composer-submit/prompt-composer-submit-state';
13
+ export { provideThreadState, injectThreadState } from './thread/thread-state';
14
+ export { provideThreadSuggestionState, injectThreadSuggestionState, } from './thread-suggestion/thread-suggestion-state';
15
+ export { provideThreadViewportState, injectThreadViewportState, } from './thread-viewport/thread-viewport-state';
16
+ export { provideThreadMessageState, injectThreadMessageState, } from './thread-message/thread-message-state';
@@ -0,0 +1,17 @@
1
+ import type { NgpPromptComposer } from './prompt-composer';
2
+ /**
3
+ * The state token for the PromptComposer primitive.
4
+ */
5
+ export declare const NgpPromptComposerStateToken: import("@angular/core").InjectionToken<NgpPromptComposer>;
6
+ /**
7
+ * Provides the PromptComposer state.
8
+ */
9
+ export declare const providePromptComposerState: (options?: import("ng-primitives/state").CreateStateProviderOptions) => import("@angular/core").FactoryProvider;
10
+ /**
11
+ * Injects the PromptComposer state.
12
+ */
13
+ export declare const injectPromptComposerState: <U = NgpPromptComposer>(injectOptions?: import("@angular/core").InjectOptions) => import("@angular/core").Signal<import("ng-primitives/state").State<U>>;
14
+ /**
15
+ * The PromptComposer state registration function.
16
+ */
17
+ export declare const promptComposerState: <U>(state: U) => import("ng-primitives/state").CreatedState<U>;
@@ -0,0 +1,23 @@
1
+ import * as i0 from "@angular/core";
2
+ export declare class NgpPromptComposer {
3
+ private readonly thread;
4
+ /** Emits whenever the user submits the prompt. */
5
+ readonly submit: import("@angular/core").OutputEmitterRef<string>;
6
+ /** @internal Store the current prompt text. */
7
+ readonly prompt: import("@angular/core").WritableSignal<string>;
8
+ /** @internal Track whether the prompt is currently being dictated */
9
+ readonly isDictating: import("@angular/core").WritableSignal<boolean>;
10
+ /** @internal Determine whether the prompt input has content */
11
+ readonly hasPrompt: import("@angular/core").Signal<boolean>;
12
+ /** Whether dictation is supported by the browser */
13
+ readonly dictationSupported: boolean;
14
+ /** The state of the prompt composer. */
15
+ protected readonly state: import("ng-primitives/state").CreatedState<NgpPromptComposer>;
16
+ /**
17
+ * @internal
18
+ * Submits the current prompt if there is content, and clears the input.
19
+ */
20
+ submitPrompt(): void;
21
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgpPromptComposer, never>;
22
+ static ɵdir: i0.ɵɵDirectiveDeclaration<NgpPromptComposer, "[ngpPromptComposer]", ["ngpPromptComposer"], {}, { "submit": "ngpPromptComposerSubmit"; }, never, never, true, never>;
23
+ }
@@ -0,0 +1,17 @@
1
+ import type { NgpPromptComposerDictation } from './prompt-composer-dictation';
2
+ /**
3
+ * The state token for the PromptComposerDictation primitive.
4
+ */
5
+ export declare const NgpPromptComposerDictationStateToken: import("@angular/core").InjectionToken<NgpPromptComposerDictation>;
6
+ /**
7
+ * Provides the PromptComposerDictation state.
8
+ */
9
+ export declare const providePromptComposerDictationState: (options?: import("ng-primitives/state").CreateStateProviderOptions) => import("@angular/core").FactoryProvider;
10
+ /**
11
+ * Injects the PromptComposerDictation state.
12
+ */
13
+ export declare const injectPromptComposerDictationState: <U = NgpPromptComposerDictation>(injectOptions?: import("@angular/core").InjectOptions) => import("@angular/core").Signal<import("ng-primitives/state").State<U>>;
14
+ /**
15
+ * The PromptComposerDictation state registration function.
16
+ */
17
+ export declare const promptComposerDictationState: <U>(state: U) => import("ng-primitives/state").CreatedState<U>;
@@ -0,0 +1,29 @@
1
+ import { BooleanInput } from '@angular/cdk/coercion';
2
+ import { OnDestroy } from '@angular/core';
3
+ import * as i0 from "@angular/core";
4
+ declare global {
5
+ interface Window {
6
+ SpeechRecognition: any;
7
+ webkitSpeechRecognition: any;
8
+ }
9
+ }
10
+ export declare class NgpPromptComposerDictation implements OnDestroy {
11
+ protected readonly composer: import("@angular/core").Signal<import("ng-primitives/state").State<import("ng-primitives/ai").NgpPromptComposer>>;
12
+ private recognition;
13
+ private basePrompt;
14
+ /** Whether the submit button should be disabled. */
15
+ readonly disabled: import("@angular/core").InputSignalWithTransform<boolean, BooleanInput>;
16
+ /** Whether dictation is currently active */
17
+ readonly isDictating: import("@angular/core").Signal<boolean>;
18
+ /** The state of the prompt composer. */
19
+ protected readonly state: import("ng-primitives/state").CreatedState<NgpPromptComposerDictation>;
20
+ constructor();
21
+ ngOnDestroy(): void;
22
+ protected onClick(): void;
23
+ protected onKeydown(event: KeyboardEvent): void;
24
+ private initializeSpeechRecognition;
25
+ private startDictation;
26
+ private stopDictation;
27
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgpPromptComposerDictation, never>;
28
+ static ɵdir: i0.ɵɵDirectiveDeclaration<NgpPromptComposerDictation, "button[ngpPromptComposerDictation]", ["ngpPromptComposerDictation"], { "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
29
+ }
@@ -0,0 +1,17 @@
1
+ import type { NgpPromptComposerInput } from './prompt-composer-input';
2
+ /**
3
+ * The state token for the PromptComposerInput primitive.
4
+ */
5
+ export declare const NgpPromptComposerInputStateToken: import("@angular/core").InjectionToken<NgpPromptComposerInput>;
6
+ /**
7
+ * Provides the PromptComposerInput state.
8
+ */
9
+ export declare const providePromptComposerInputState: (options?: import("ng-primitives/state").CreateStateProviderOptions) => import("@angular/core").FactoryProvider;
10
+ /**
11
+ * Injects the PromptComposerInput state.
12
+ */
13
+ export declare const injectPromptComposerInputState: <U = NgpPromptComposerInput>(injectOptions?: import("@angular/core").InjectOptions) => import("@angular/core").Signal<import("ng-primitives/state").State<U>>;
14
+ /**
15
+ * The PromptComposerInput state registration function.
16
+ */
17
+ export declare const promptComposerInputState: <U>(state: U) => import("ng-primitives/state").CreatedState<U>;
@@ -0,0 +1,16 @@
1
+ import * as i0 from "@angular/core";
2
+ export declare class NgpPromptComposerInput {
3
+ protected readonly thread: import("@angular/core").Signal<import("ng-primitives/state").State<import("ng-primitives/ai").NgpThread>>;
4
+ private readonly composer;
5
+ private readonly element;
6
+ /** The state of the prompt composer input. */
7
+ protected readonly state: import("ng-primitives/state").CreatedState<NgpPromptComposerInput>;
8
+ constructor();
9
+ /**
10
+ * If the user presses Enter, the form will be submitted, unless they are holding Shift.
11
+ * This directive automatically handles that behavior.
12
+ */
13
+ protected onEnterKey(event: KeyboardEvent): void;
14
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgpPromptComposerInput, never>;
15
+ static ɵdir: i0.ɵɵDirectiveDeclaration<NgpPromptComposerInput, "input[ngpPromptComposerInput], textarea[ngpPromptComposerInput]", ["ngpPromptComposerInput"], {}, {}, never, never, true, never>;
16
+ }
@@ -0,0 +1,17 @@
1
+ import type { NgpPromptComposerSubmit } from './prompt-composer-submit';
2
+ /**
3
+ * The state token for the PromptComposerSubmit primitive.
4
+ */
5
+ export declare const NgpPromptComposerSubmitStateToken: import("@angular/core").InjectionToken<NgpPromptComposerSubmit>;
6
+ /**
7
+ * Provides the PromptComposerSubmit state.
8
+ */
9
+ export declare const providePromptComposerSubmitState: (options?: import("ng-primitives/state").CreateStateProviderOptions) => import("@angular/core").FactoryProvider;
10
+ /**
11
+ * Injects the PromptComposerSubmit state.
12
+ */
13
+ export declare const injectPromptComposerSubmitState: <U = NgpPromptComposerSubmit>(injectOptions?: import("@angular/core").InjectOptions) => import("@angular/core").Signal<import("ng-primitives/state").State<U>>;
14
+ /**
15
+ * The PromptComposerSubmit state registration function.
16
+ */
17
+ export declare const promptComposerSubmitState: <U>(state: U) => import("ng-primitives/state").CreatedState<U>;
@@ -0,0 +1,15 @@
1
+ import { BooleanInput } from '@angular/cdk/coercion';
2
+ import * as i0 from "@angular/core";
3
+ export declare class NgpPromptComposerSubmit {
4
+ protected readonly composer: import("@angular/core").Signal<import("ng-primitives/state").State<import("ng-primitives/ai").NgpPromptComposer>>;
5
+ /** Whether the submit button should be disabled */
6
+ readonly disabled: import("@angular/core").InputSignalWithTransform<boolean, BooleanInput>;
7
+ /** Whether dictation is currently active */
8
+ readonly isDictating: import("@angular/core").Signal<boolean>;
9
+ /** The state of the prompt composer submit. */
10
+ protected readonly state: import("ng-primitives/state").CreatedState<NgpPromptComposerSubmit>;
11
+ constructor();
12
+ protected onClick(): void;
13
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgpPromptComposerSubmit, never>;
14
+ static ɵdir: i0.ɵɵDirectiveDeclaration<NgpPromptComposerSubmit, "button[ngpPromptComposerSubmit]", ["ngpPromptComposerSubmit"], { "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
15
+ }
@@ -0,0 +1,17 @@
1
+ import type { NgpThread } from './thread';
2
+ /**
3
+ * The state token for the Thread primitive.
4
+ */
5
+ export declare const NgpThreadStateToken: import("@angular/core").InjectionToken<NgpThread>;
6
+ /**
7
+ * Provides the Thread state.
8
+ */
9
+ export declare const provideThreadState: (options?: import("ng-primitives/state").CreateStateProviderOptions) => import("@angular/core").FactoryProvider;
10
+ /**
11
+ * Injects the Thread state.
12
+ */
13
+ export declare const injectThreadState: <U = NgpThread>(injectOptions?: import("@angular/core").InjectOptions) => import("@angular/core").Signal<import("ng-primitives/state").State<U>>;
14
+ /**
15
+ * The Thread state registration function.
16
+ */
17
+ export declare const threadState: <U>(state: U) => import("ng-primitives/state").CreatedState<U>;
@@ -0,0 +1,23 @@
1
+ import { Subject } from 'rxjs';
2
+ import { NgpThreadMessage } from '../thread-message/thread-message';
3
+ import * as i0 from "@angular/core";
4
+ export declare class NgpThread {
5
+ private messages;
6
+ /** @internal emit event to trigger scrolling to bottom */
7
+ readonly scrollRequest: Subject<ScrollBehavior>;
8
+ /** @internal emit event to trigger setting the prompt */
9
+ readonly requestPrompt: Subject<string>;
10
+ /** The state of the thread. */
11
+ protected readonly state: import("ng-primitives/state").CreatedState<NgpThread>;
12
+ scrollToBottom(behavior: ScrollBehavior): void;
13
+ /** @internal Register a message with the thread */
14
+ registerMessage(message: NgpThreadMessage): void;
15
+ /** @internal Unregister a message from the thread */
16
+ unregisterMessage(message: NgpThreadMessage): void;
17
+ /** @internal Determine if the given message is the last message in the thread */
18
+ isLastMessage(message: NgpThreadMessage): boolean;
19
+ /** @internal Set the prompt text in the associated prompt composer */
20
+ setPrompt(value: string): void;
21
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgpThread, never>;
22
+ static ɵdir: i0.ɵɵDirectiveDeclaration<NgpThread, "[ngpThread]", ["ngpThread"], {}, {}, never, never, true, never>;
23
+ }
@@ -0,0 +1,17 @@
1
+ import type { NgpThreadMessage } from './thread-message';
2
+ /**
3
+ * The state token for the ThreadMessage primitive.
4
+ */
5
+ export declare const NgpThreadMessageStateToken: import("@angular/core").InjectionToken<NgpThreadMessage>;
6
+ /**
7
+ * Provides the ThreadMessage state.
8
+ */
9
+ export declare const provideThreadMessageState: (options?: import("ng-primitives/state").CreateStateProviderOptions) => import("@angular/core").FactoryProvider;
10
+ /**
11
+ * Injects the ThreadMessage state.
12
+ */
13
+ export declare const injectThreadMessageState: <U = NgpThreadMessage>(injectOptions?: import("@angular/core").InjectOptions) => import("@angular/core").Signal<import("ng-primitives/state").State<U>>;
14
+ /**
15
+ * The ThreadMessage state registration function.
16
+ */
17
+ export declare const threadMessageState: <U>(state: U) => import("ng-primitives/state").CreatedState<U>;
@@ -0,0 +1,11 @@
1
+ import * as i0 from "@angular/core";
2
+ export declare class NgpThreadMessage {
3
+ private readonly elementRef;
4
+ private readonly destroyRef;
5
+ private readonly thread;
6
+ /** The state of the thread message. */
7
+ protected readonly state: import("ng-primitives/state").CreatedState<NgpThreadMessage>;
8
+ constructor();
9
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgpThreadMessage, never>;
10
+ static ɵdir: i0.ɵɵDirectiveDeclaration<NgpThreadMessage, "[ngpThreadMessage]", ["ngpThreadMessage"], {}, {}, never, never, true, never>;
11
+ }
@@ -0,0 +1,17 @@
1
+ import type { NgpThreadSuggestion } from './thread-suggestion';
2
+ /**
3
+ * The state token for the ThreadSuggestion primitive.
4
+ */
5
+ export declare const NgpThreadSuggestionStateToken: import("@angular/core").InjectionToken<NgpThreadSuggestion>;
6
+ /**
7
+ * Provides the ThreadSuggestion state.
8
+ */
9
+ export declare const provideThreadSuggestionState: (options?: import("ng-primitives/state").CreateStateProviderOptions) => import("@angular/core").FactoryProvider;
10
+ /**
11
+ * Injects the ThreadSuggestion state.
12
+ */
13
+ export declare const injectThreadSuggestionState: <U = NgpThreadSuggestion>(injectOptions?: import("@angular/core").InjectOptions) => import("@angular/core").Signal<import("ng-primitives/state").State<U>>;
14
+ /**
15
+ * The ThreadSuggestion state registration function.
16
+ */
17
+ export declare const threadSuggestionState: <U>(state: U) => import("ng-primitives/state").CreatedState<U>;
@@ -0,0 +1,14 @@
1
+ import { BooleanInput } from '@angular/cdk/coercion';
2
+ import * as i0 from "@angular/core";
3
+ export declare class NgpThreadSuggestion {
4
+ private readonly thread;
5
+ /** The suggested text to display in the input field. */
6
+ readonly suggestion: import("@angular/core").InputSignal<string>;
7
+ /** Whether the suggestion should populate the prompt when clicked. */
8
+ readonly setPromptOnClick: import("@angular/core").InputSignalWithTransform<boolean, BooleanInput>;
9
+ /** The state of the thread suggestion. */
10
+ protected readonly state: import("ng-primitives/state").CreatedState<NgpThreadSuggestion>;
11
+ submitSuggestion(): void;
12
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgpThreadSuggestion, never>;
13
+ static ɵdir: i0.ɵɵDirectiveDeclaration<NgpThreadSuggestion, "button[ngpThreadSuggestion]", ["ngpThreadSuggestion"], { "suggestion": { "alias": "ngpThreadSuggestion"; "required": false; "isSignal": true; }; "setPromptOnClick": { "alias": "ngpThreadSuggestionSetPromptOnClick"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
14
+ }
@@ -0,0 +1,17 @@
1
+ import type { NgpThreadViewport } from './thread-viewport';
2
+ /**
3
+ * The state token for the ThreadViewport primitive.
4
+ */
5
+ export declare const NgpThreadViewportStateToken: import("@angular/core").InjectionToken<NgpThreadViewport>;
6
+ /**
7
+ * Provides the ThreadViewport state.
8
+ */
9
+ export declare const provideThreadViewportState: (options?: import("ng-primitives/state").CreateStateProviderOptions) => import("@angular/core").FactoryProvider;
10
+ /**
11
+ * Injects the ThreadViewport state.
12
+ */
13
+ export declare const injectThreadViewportState: <U = NgpThreadViewport>(injectOptions?: import("@angular/core").InjectOptions) => import("@angular/core").Signal<import("ng-primitives/state").State<U>>;
14
+ /**
15
+ * The ThreadViewport state registration function.
16
+ */
17
+ export declare const threadViewportState: <U>(state: U) => import("ng-primitives/state").CreatedState<U>;
@@ -0,0 +1,34 @@
1
+ import { BooleanInput, NumberInput } from '@angular/cdk/coercion';
2
+ import * as i0 from "@angular/core";
3
+ export declare class NgpThreadViewport {
4
+ private readonly thread;
5
+ private readonly elementRef;
6
+ /**
7
+ * The distance in pixels from the bottom of the scrollable container that is considered "at the bottom".
8
+ * When the user scrolls within this threshold, the thread is treated as being at the bottom.
9
+ * This value is used to determine whether automatic scrolling to the bottom should occur,
10
+ * for example when new content is added or the container is resized.
11
+ *
12
+ * @default 70
13
+ */
14
+ readonly threshold: import("@angular/core").InputSignalWithTransform<number, NumberInput>;
15
+ /**
16
+ * Whether the thread should automatically scroll to the bottom when new content is added.
17
+ */
18
+ readonly autoScroll: import("@angular/core").InputSignalWithTransform<boolean, BooleanInput>;
19
+ /** Store the last known scroll position */
20
+ private lastScrollTop;
21
+ /** Determine if we are at the bottom of the scrollable container (within the threshold) */
22
+ protected isAtBottom: boolean;
23
+ /** The state of the thread viewport. */
24
+ protected readonly state: import("ng-primitives/state").CreatedState<NgpThreadViewport>;
25
+ constructor();
26
+ /**
27
+ * Scroll the container to the bottom.
28
+ * @internal
29
+ */
30
+ scrollToBottom(behavior: ScrollBehavior): void;
31
+ protected onScroll(): void;
32
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgpThreadViewport, never>;
33
+ static ɵdir: i0.ɵɵDirectiveDeclaration<NgpThreadViewport, "[ngpThreadViewport]", ["ngpThreadViewport"], { "threshold": { "alias": "ngpThreadViewportThreshold"; "required": false; "isSignal": true; }; "autoScroll": { "alias": "ngpThreadViewportAutoScroll"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
34
+ }
@@ -183,6 +183,38 @@ export declare class NgpCombobox {
183
183
  * @internal
184
184
  */
185
185
  unregisterOption(option: NgpComboboxOption): void;
186
+ /**
187
+ * Focus the combobox.
188
+ * When an input element is present, it will be focused.
189
+ * Otherwise, the combobox element itself will be focused.
190
+ * This enables keyboard navigation for comboboxes without input elements.
191
+ * @internal
192
+ */
193
+ focus(): void;
194
+ /**
195
+ * Handle keydown events for keyboard navigation and accessibility.
196
+ * Supports:
197
+ * - Arrow Down: Open dropdown or navigate to next option
198
+ * - Arrow Up: Open dropdown or navigate to previous option
199
+ * - Home: Navigate to first option
200
+ * - End: Navigate to last option
201
+ * - Enter: Select the currently active option
202
+ * - Escape: Close the dropdown
203
+ * @param event - The keyboard event
204
+ * @internal
205
+ */
206
+ protected handleKeydown(event: KeyboardEvent): void;
207
+ /**
208
+ * Handle blur events to manage dropdown closing behavior.
209
+ * The dropdown will remain open if focus moves to:
210
+ * - The dropdown itself
211
+ * - The combobox button
212
+ * - The combobox input
213
+ * Otherwise, the dropdown will be closed.
214
+ * @param event - The focus event
215
+ * @internal
216
+ */
217
+ protected onBlur(event: FocusEvent): void;
186
218
  static ɵfac: i0.ɵɵFactoryDeclaration<NgpCombobox, never>;
187
219
  static ɵdir: i0.ɵɵDirectiveDeclaration<NgpCombobox, "[ngpCombobox]", ["ngpCombobox"], { "value": { "alias": "ngpComboboxValue"; "required": false; "isSignal": true; }; "multiple": { "alias": "ngpComboboxMultiple"; "required": false; "isSignal": true; }; "disabled": { "alias": "ngpComboboxDisabled"; "required": false; "isSignal": true; }; "allowDeselect": { "alias": "ngpComboboxAllowDeselect"; "required": false; "isSignal": true; }; "compareWith": { "alias": "ngpComboboxCompareWith"; "required": false; "isSignal": true; }; "placement": { "alias": "ngpComboboxDropdownPlacement"; "required": false; "isSignal": true; }; "container": { "alias": "ngpComboboxDropdownContainer"; "required": false; "isSignal": true; }; }, { "valueChange": "ngpComboboxValueChange"; "openChange": "ngpComboboxOpenChange"; }, never, never, true, never>;
188
220
  }
@@ -0,0 +1,9 @@
1
+ import type { NgpComboboxOption } from './combobox-option/combobox-option';
2
+ /**
3
+ * Check if all regular options (excluding 'all' and undefined) are selected.
4
+ * @param options All available options
5
+ * @param selectedValues Currently selected values
6
+ * @param compareWith Comparison function
7
+ * @returns true if all regular options are selected
8
+ */
9
+ export declare function areAllOptionsSelected(options: NgpComboboxOption[], selectedValues: any[], compareWith: (a: any, b: any) => boolean): boolean;