@magicx-eng/ai-autocomplete-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/README.md +582 -0
- package/esm2020/lib/ai-autocomplete/ai-autocomplete.component.mjs +365 -0
- package/esm2020/lib/ai-autocomplete/index.mjs +2 -0
- package/esm2020/lib/ai-autocomplete-dropdown/ai-autocomplete-dropdown.component.mjs +81 -0
- package/esm2020/lib/ai-autocomplete-dropdown/index.mjs +2 -0
- package/esm2020/lib/ai-autocomplete.module.mjs +26 -0
- package/esm2020/lib/controller/ai-autocomplete.controller.mjs +226 -0
- package/esm2020/lib/controller/index.mjs +2 -0
- package/esm2020/lib/controller/observables.mjs +24 -0
- package/esm2020/lib/input/ai-autocomplete-input.directive.mjs +180 -0
- package/esm2020/lib/input/index.mjs +2 -0
- package/esm2020/lib/internal/editor-host/editor-host.directive.mjs +253 -0
- package/esm2020/lib/internal/pill-list/pill-list.component.mjs +65 -0
- package/esm2020/lib/internal/suggestion-grid/suggestion-grid.component.mjs +97 -0
- package/esm2020/lib/internal/suggestion-item/suggestion-item.component.mjs +76 -0
- package/esm2020/lib/shared/types.mjs +2 -0
- package/esm2020/magicx-eng-ai-autocomplete-angular.mjs +5 -0
- package/esm2020/public-api.mjs +18 -0
- package/fesm2015/magicx-eng-ai-autocomplete-angular.mjs +1386 -0
- package/fesm2015/magicx-eng-ai-autocomplete-angular.mjs.map +1 -0
- package/fesm2020/magicx-eng-ai-autocomplete-angular.mjs +1370 -0
- package/fesm2020/magicx-eng-ai-autocomplete-angular.mjs.map +1 -0
- package/index.d.ts +6 -0
- package/lib/ai-autocomplete/ai-autocomplete.component.d.ts +113 -0
- package/lib/ai-autocomplete/ai-autocomplete.component.d.ts.map +1 -0
- package/lib/ai-autocomplete/index.d.ts +2 -0
- package/lib/ai-autocomplete/index.d.ts.map +1 -0
- package/lib/ai-autocomplete-dropdown/ai-autocomplete-dropdown.component.d.ts +51 -0
- package/lib/ai-autocomplete-dropdown/ai-autocomplete-dropdown.component.d.ts.map +1 -0
- package/lib/ai-autocomplete-dropdown/index.d.ts +2 -0
- package/lib/ai-autocomplete-dropdown/index.d.ts.map +1 -0
- package/lib/ai-autocomplete.module.d.ts +18 -0
- package/lib/ai-autocomplete.module.d.ts.map +1 -0
- package/lib/controller/ai-autocomplete.controller.d.ts +131 -0
- package/lib/controller/ai-autocomplete.controller.d.ts.map +1 -0
- package/lib/controller/index.d.ts +2 -0
- package/lib/controller/index.d.ts.map +1 -0
- package/lib/controller/observables.d.ts +22 -0
- package/lib/controller/observables.d.ts.map +1 -0
- package/lib/input/ai-autocomplete-input.directive.d.ts +60 -0
- package/lib/input/ai-autocomplete-input.directive.d.ts.map +1 -0
- package/lib/input/index.d.ts +2 -0
- package/lib/input/index.d.ts.map +1 -0
- package/lib/internal/editor-host/editor-host.directive.d.ts +46 -0
- package/lib/internal/editor-host/editor-host.directive.d.ts.map +1 -0
- package/lib/internal/pill-list/pill-list.component.d.ts +35 -0
- package/lib/internal/pill-list/pill-list.component.d.ts.map +1 -0
- package/lib/internal/suggestion-grid/suggestion-grid.component.d.ts +37 -0
- package/lib/internal/suggestion-grid/suggestion-grid.component.d.ts.map +1 -0
- package/lib/internal/suggestion-item/suggestion-item.component.d.ts +33 -0
- package/lib/internal/suggestion-item/suggestion-item.component.d.ts.map +1 -0
- package/lib/shared/types.d.ts +125 -0
- package/lib/shared/types.d.ts.map +1 -0
- package/magicx-eng-ai-autocomplete-angular.d.ts.map +1 -0
- package/package.json +46 -0
- package/public-api.d.ts +15 -0
- package/public-api.d.ts.map +1 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { type CompletedParamState, type Segment, type Suggestion, type SuggestionOption } from "@magicx-eng/ai-autocomplete-vanilla";
|
|
2
|
+
import { type Observable } from "rxjs";
|
|
3
|
+
import type { AIAutocompleteControllerOptions, AIAutocompleteControllerState, AIAutocompleteControllerUpdate, AIAutocompleteDropdownState } from "../shared/types";
|
|
4
|
+
/**
|
|
5
|
+
* Tier 2 logic surface for `@magicx-eng/ai-autocomplete-angular` — the Angular
|
|
6
|
+
* equivalent of React's `useAIAutocomplete()` hook. Wraps a headless
|
|
7
|
+
* `@magicx-eng/ai-autocomplete-vanilla` core and exposes its state as RxJS
|
|
8
|
+
* observables plus thin action methods.
|
|
9
|
+
*
|
|
10
|
+
* Per TDB §3.3, the controller is consumer-managed — the consumer creates it
|
|
11
|
+
* with `new`, holds the reference, and **must call `destroy()`** in their
|
|
12
|
+
* own `ngOnDestroy`. The Tier 1 `<ai-autocomplete>` component does this
|
|
13
|
+
* automatically; Tier 2 consumers do not get auto-cleanup.
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export declare class AIAutocompleteController {
|
|
18
|
+
private readonly core;
|
|
19
|
+
private readonly rawState$;
|
|
20
|
+
private readonly unsubscribeCore;
|
|
21
|
+
private isDestroyed;
|
|
22
|
+
/** Plain-text content of the editor. */
|
|
23
|
+
readonly text$: Observable<string>;
|
|
24
|
+
/** Completed (bold) params currently in the editor. */
|
|
25
|
+
readonly completedParams$: Observable<CompletedParamState[]>;
|
|
26
|
+
/** Actionable suggestion pills (first one is the active pill). */
|
|
27
|
+
readonly suggestionPills$: Observable<Suggestion[]>;
|
|
28
|
+
/** Text + completed-param segments for rendering the editor body. */
|
|
29
|
+
readonly segments$: Observable<Segment[]>;
|
|
30
|
+
/** ID of the most-recently-promoted param (drives shimmer animation). */
|
|
31
|
+
readonly newParamId$: Observable<string | null>;
|
|
32
|
+
/** All suggestions from the server (including non-actionable ones). */
|
|
33
|
+
readonly suggestions$: Observable<Suggestion[]>;
|
|
34
|
+
/** Currently highlighted dropdown option index. -1 = none. */
|
|
35
|
+
readonly activeIndex$: Observable<number>;
|
|
36
|
+
/**
|
|
37
|
+
* UI-visible loading flag — suppressed during the post-select streak
|
|
38
|
+
* animation and during re-edit (cached options stay visible there). Use
|
|
39
|
+
* this instead of the raw core state for any loading-skeleton binding.
|
|
40
|
+
*/
|
|
41
|
+
readonly isLoading$: Observable<boolean>;
|
|
42
|
+
/** Server-reported "query is complete" flag. */
|
|
43
|
+
readonly isReady$: Observable<boolean>;
|
|
44
|
+
/** Whether the editor currently has focus. */
|
|
45
|
+
readonly isFocused$: Observable<boolean>;
|
|
46
|
+
/** Whether the dropdown should currently be visible. */
|
|
47
|
+
readonly isDropdownOpen$: Observable<boolean>;
|
|
48
|
+
/** Server-suggested placeholder text for the editor. */
|
|
49
|
+
readonly placeholderText$: Observable<string>;
|
|
50
|
+
/** Last fetch error, or null. */
|
|
51
|
+
readonly error$: Observable<Error | null>;
|
|
52
|
+
/** Param currently being re-edited, or null. */
|
|
53
|
+
readonly editingParam$: Observable<CompletedParamState | null>;
|
|
54
|
+
/** Plain-text offset where the edit region starts, or null. */
|
|
55
|
+
readonly editingAnchor$: Observable<number | null>;
|
|
56
|
+
/** Live caret offset within the editor. */
|
|
57
|
+
readonly caretOffset$: Observable<number | null>;
|
|
58
|
+
/**
|
|
59
|
+
* Snapshot of every public field in one object. Convenient for
|
|
60
|
+
* `*ngIf="ctrl.state$ | async as state"` templating — aliases all fields
|
|
61
|
+
* under a single subscription instead of multiple `| async` pipes.
|
|
62
|
+
*/
|
|
63
|
+
readonly state$: Observable<AIAutocompleteControllerState>;
|
|
64
|
+
/**
|
|
65
|
+
* Composite state for the dropdown view. Tier 2 consumers spread this into
|
|
66
|
+
* `<ai-autocomplete-dropdown>`; Tier 1 uses the same shape internally.
|
|
67
|
+
*/
|
|
68
|
+
readonly dropdown$: Observable<AIAutocompleteDropdownState>;
|
|
69
|
+
/**
|
|
70
|
+
* Throws if invoked outside a browser environment. For SSR / Angular
|
|
71
|
+
* Universal, gate construction with `isPlatformBrowser` — see TDB §16.3.
|
|
72
|
+
*/
|
|
73
|
+
constructor(opts?: AIAutocompleteControllerOptions);
|
|
74
|
+
/** Stable ARIA listbox ID for the dropdown. Pass to `<textarea aria-controls="...">`. */
|
|
75
|
+
get listboxId(): string;
|
|
76
|
+
/** Whether `destroy()` has been called. After destruction all action methods no-op. */
|
|
77
|
+
get destroyed(): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Synchronous snapshot of the controller's current public state. Mirrors
|
|
80
|
+
* the latest emission of `state$`. Useful in callbacks where you can't
|
|
81
|
+
* `subscribe` (e.g. inside an event handler).
|
|
82
|
+
*/
|
|
83
|
+
getState(): AIAutocompleteControllerState;
|
|
84
|
+
/** Clear all state, rotate `session_id`, and re-fetch. Call after submit. */
|
|
85
|
+
reset(): void;
|
|
86
|
+
/** Pick a dropdown option (or replace the re-edited param if in re-edit mode). */
|
|
87
|
+
selectOption(option: SuggestionOption): void;
|
|
88
|
+
/** Promote the pill at `index` to active (front of the list). */
|
|
89
|
+
setActivePill(index: number): void;
|
|
90
|
+
/** Drop the last completed param's "completed" status. Text stays as plain text. */
|
|
91
|
+
removeLastParam(): void;
|
|
92
|
+
/** Clear the shimmer animation state for the most-recently-added param. */
|
|
93
|
+
clearNewParamId(): void;
|
|
94
|
+
/** Controlled-mode setter for editor text. */
|
|
95
|
+
setValue(text: string): void;
|
|
96
|
+
/** Controlled-mode setter for completed params. */
|
|
97
|
+
setCompletedParams(params: CompletedParamState[]): void;
|
|
98
|
+
/** Forward plain-text input from the consumer's `<textarea>` to the core. */
|
|
99
|
+
handleTextChange(value: string): void;
|
|
100
|
+
/** Forward keyboard events from the consumer's `<textarea>` to the core. */
|
|
101
|
+
handleKeyDown(event: KeyboardEvent): void;
|
|
102
|
+
/** Notify the core of focus state. */
|
|
103
|
+
setFocused(focused: boolean): void;
|
|
104
|
+
/** Enter re-edit mode for the bold param with the given id. */
|
|
105
|
+
startEditingParam(paramId: string): void;
|
|
106
|
+
/** Exit re-edit mode without changing the bold param. */
|
|
107
|
+
exitEditMode(): void;
|
|
108
|
+
/** Forward post-input caret position (extends the edit tail). */
|
|
109
|
+
handleCaretAfterInput(offset: number | null): void;
|
|
110
|
+
/** Forward selection-only caret moves (may exit re-edit). */
|
|
111
|
+
handleCaretMove(offset: number | null): void;
|
|
112
|
+
/** Replace the bold param being re-edited. Returns true when applied. */
|
|
113
|
+
replaceEditingRange(replacement: string): boolean;
|
|
114
|
+
/** Set the highlighted option index (typically driven by hover). */
|
|
115
|
+
setActiveDropdownIndex(index: number): void;
|
|
116
|
+
/**
|
|
117
|
+
* Apply runtime changes to a subset of options. Event callbacks
|
|
118
|
+
* (`onSubmit`, `onError`, etc.) cannot be swapped this way — they are
|
|
119
|
+
* registered once at construction (matches the React hook's design). For
|
|
120
|
+
* dynamic event reactivity, subscribe to the corresponding observable
|
|
121
|
+
* (e.g. `text$` instead of `onChange`).
|
|
122
|
+
*/
|
|
123
|
+
update(opts: AIAutocompleteControllerUpdate): void;
|
|
124
|
+
/**
|
|
125
|
+
* Release all resources — unsubscribes from the core, destroys the core,
|
|
126
|
+
* and completes the internal state subject. Safe to call multiple times.
|
|
127
|
+
* After destruction, action methods no-op silently.
|
|
128
|
+
*/
|
|
129
|
+
destroy(): void;
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=ai-autocomplete.controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-autocomplete.controller.d.ts","sourceRoot":"","sources":["../../../src/lib/controller/ai-autocomplete.controller.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,mBAAmB,EAGxB,KAAK,OAAO,EACZ,KAAK,UAAU,EACf,KAAK,gBAAgB,EACtB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAwB,KAAK,UAAU,EAAe,MAAM,MAAM,CAAC;AAC1E,OAAO,KAAK,EACV,+BAA+B,EAC/B,6BAA6B,EAC7B,8BAA8B,EAC9B,2BAA2B,EAC5B,MAAM,iBAAiB,CAAC;AAGzB;;;;;;;;;;;;GAYG;AACH,qBAAa,wBAAwB;IACnC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAqB;IAC1C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA6B;I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qB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAIlD,6DAA6D;IAC7D,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAI5C,yEAAyE;IACzE,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IAIjD,oEAAoE;IACpE,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAM3C;;;;;;OAMG;IACH,MAAM,CAAC,IAAI,EAAE,8BAA8B,GAAG,IAAI;IAIlD;;;;OAIG;IACH,OAAO,IAAI,IAAI;CAOhB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/controller/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type Observable } from "rxjs";
|
|
2
|
+
/**
|
|
3
|
+
* Per-field observable derivation factory. Enforces the §19.4 invariant:
|
|
4
|
+
*
|
|
5
|
+
* - `distinctUntilChanged` — prevents re-emission storms when the upstream
|
|
6
|
+
* state object ticks but the field a consumer cares about hasn't changed.
|
|
7
|
+
* Without this, every keystroke would re-render every async-pipe binding
|
|
8
|
+
* in the consumer's template even when nothing changed for that binding.
|
|
9
|
+
* - `shareReplay({ bufferSize: 1, refCount: true })` — guarantees that
|
|
10
|
+
* multiple subscribers (multiple `async` pipes in a template, e.g.
|
|
11
|
+
* `*ngIf="isLoading$ | async"` and `[disabled]="isLoading$ | async"`)
|
|
12
|
+
* share a single upstream subscription. `refCount: true` is non-obvious
|
|
13
|
+
* but essential: without it, the inner subscription survives after the
|
|
14
|
+
* last subscriber unmounts, leaking the chain back to `state$`.
|
|
15
|
+
*
|
|
16
|
+
* Every public observable on {@link AIAutocompleteController} must go through
|
|
17
|
+
* this factory — no exceptions.
|
|
18
|
+
*
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export declare function deriveField<T, R>(source$: Observable<T>, selector: (value: T) => R, equalityFn?: (a: R, b: R) => boolean): Observable<R>;
|
|
22
|
+
//# sourceMappingURL=observables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observables.d.ts","sourceRoot":"","sources":["../../../src/lib/controller/observables.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,UAAU,EAAe,MAAM,MAAM,CAAC;AAE/E;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAC9B,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,EACtB,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,EACzB,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAO,GACnC,UAAU,CAAC,CAAC,CAAC,CAMf"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { type OnDestroy, type OnInit } from "@angular/core";
|
|
2
|
+
import { type ControlValueAccessor } from "@angular/forms";
|
|
3
|
+
import type { AIAutocompleteController } from "../controller/ai-autocomplete.controller";
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
/**
|
|
6
|
+
* Tier 2 input binder. Attach to a `<textarea>` or `<input>` and pass an
|
|
7
|
+
* {@link AIAutocompleteController}:
|
|
8
|
+
*
|
|
9
|
+
* ```html
|
|
10
|
+
* <textarea [aiaInput]="ac"></textarea>
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* The directive wires the input's events (input/keydown/focus/blur) to the
|
|
14
|
+
* controller, mirrors controller state into ARIA attributes
|
|
15
|
+
* (`role="combobox"`, `aria-expanded`, `aria-activedescendant`,
|
|
16
|
+
* `aria-autocomplete`, `aria-controls`), and implements
|
|
17
|
+
* {@link ControlValueAccessor} so the host element participates in Reactive
|
|
18
|
+
* Forms out of the box:
|
|
19
|
+
*
|
|
20
|
+
* ```html
|
|
21
|
+
* <textarea [aiaInput]="ac" [formControl]="myControl"></textarea>
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* Per the React hook's behavior, the first typed character is auto-capitalized
|
|
25
|
+
* — typing "h" becomes "H" before being forwarded to the controller. The
|
|
26
|
+
* cursor position is preserved across that rewrite.
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export declare class AIAutocompleteInputDirective implements OnInit, OnDestroy, ControlValueAccessor {
|
|
31
|
+
/**
|
|
32
|
+
* The {@link AIAutocompleteController} that owns the autocomplete state.
|
|
33
|
+
* Required. The directive throws on init if this is missing.
|
|
34
|
+
*/
|
|
35
|
+
controller: AIAutocompleteController;
|
|
36
|
+
private readonly el;
|
|
37
|
+
private readonly renderer;
|
|
38
|
+
private readonly destroy$;
|
|
39
|
+
private onChangeFn;
|
|
40
|
+
private onTouchedFn;
|
|
41
|
+
ngOnInit(): void;
|
|
42
|
+
ngOnDestroy(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Auto-capitalizes the first character on the user's first keystroke so the
|
|
45
|
+
* server receives "Create" instead of "create". Matches React's
|
|
46
|
+
* `handleChange` in `useAIAutocomplete`. Skipped during IME composition so
|
|
47
|
+
* we don't disrupt multi-keystroke input methods (Pinyin, Hangul, etc.).
|
|
48
|
+
*/
|
|
49
|
+
onInput(event: Event): void;
|
|
50
|
+
onKeyDown(event: KeyboardEvent): void;
|
|
51
|
+
onFocus(): void;
|
|
52
|
+
onBlur(): void;
|
|
53
|
+
writeValue(value: string | null): void;
|
|
54
|
+
registerOnChange(fn: (value: string) => void): void;
|
|
55
|
+
registerOnTouched(fn: () => void): void;
|
|
56
|
+
setDisabledState(disabled: boolean): void;
|
|
57
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AIAutocompleteInputDirective, never>;
|
|
58
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<AIAutocompleteInputDirective, "[aiaInput]", never, { "controller": "aiaInput"; }, {}, never, never, true, never>;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=ai-autocomplete-input.directive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-autocomplete-input.directive.d.ts","sourceRoot":"","sources":["../../../src/lib/input/ai-autocomplete-input.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,SAAS,EACd,KAAK,MAAM,EAEZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,oBAAoB,EAAqB,MAAM,gBAAgB,CAAC;AAE9E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;;AAEzF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAoBa,4BAA6B,YAAW,MAAM,EAAE,SAAS,EAAE,oBAAoB;IAC1F;;;OAGG;IACgB,UAAU,EAAG,wBAAwB,CAAC;IAEzD,OAAO,CAAC,QAAQ,CAAC,EAAE,CAA0E;IAC7F,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqB;IAC9C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAuB;IAEhD,OAAO,CAAC,UAAU,CAAiC;IACnD,OAAO,CAAC,WAAW,CAAoB;IAEvC,QAAQ,IAAI,IAAI;IA8ChB,WAAW,IAAI,IAAI;IAOnB;;;;;OAKG;IACH,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAyB3B,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI;IAIrC,OAAO,IAAI,IAAI;IAIf,MAAM,IAAI,IAAI;IAOd,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAStC,gBAAgB,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI;IAInD,iBAAiB,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI;IAIvC,gBAAgB,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;yCAlI9B,4BAA4B;2CAA5B,4BAA4B;CAqIxC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/input/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type OnDestroy, type OnInit } from "@angular/core";
|
|
2
|
+
import type { AIAutocompleteController } from "../../controller/ai-autocomplete.controller";
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* Internal directive that owns every concern specific to running the
|
|
6
|
+
* autocomplete on top of a contentEditable host: composition state, caret
|
|
7
|
+
* tracking, selectionchange handling, `beforeinput` interception, paste
|
|
8
|
+
* sanitization, plaintext-only feature detection, segment rendering,
|
|
9
|
+
* post-promote refocus, and re-edit caret park.
|
|
10
|
+
*
|
|
11
|
+
* Mirrors `packages/react/src/hooks/useContentEditableEditor.ts` one-for-one.
|
|
12
|
+
* Used only by the Tier 1 `<ai-autocomplete>` component — never exported.
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export declare class AIAutocompleteEditorHostDirective implements OnInit, OnDestroy {
|
|
17
|
+
controller: AIAutocompleteController;
|
|
18
|
+
autoFocus: boolean;
|
|
19
|
+
private readonly el;
|
|
20
|
+
private readonly renderer;
|
|
21
|
+
private readonly zone;
|
|
22
|
+
private readonly destroy$;
|
|
23
|
+
private composing;
|
|
24
|
+
private lastInputAt;
|
|
25
|
+
private lastSeenParamId;
|
|
26
|
+
private lastEditingId;
|
|
27
|
+
private editingParamId;
|
|
28
|
+
private documentSelectionListener?;
|
|
29
|
+
private beforeInputListener?;
|
|
30
|
+
ngOnInit(): void;
|
|
31
|
+
ngOnDestroy(): void;
|
|
32
|
+
onCompositionStart(): void;
|
|
33
|
+
onCompositionEnd(): void;
|
|
34
|
+
onInput(): void;
|
|
35
|
+
onKeyDown(event: KeyboardEvent): void;
|
|
36
|
+
onPaste(event: ClipboardEvent): void;
|
|
37
|
+
onFocus(): void;
|
|
38
|
+
onBlur(): void;
|
|
39
|
+
private fireInput;
|
|
40
|
+
private bindDocumentSelectionListener;
|
|
41
|
+
private bindBeforeInputListener;
|
|
42
|
+
private bindStateSubscription;
|
|
43
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AIAutocompleteEditorHostDirective, never>;
|
|
44
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<AIAutocompleteEditorHostDirective, "[aiaEditorHost]", never, { "controller": "aiaEditorHost"; "autoFocus": "autoFocus"; }, {}, never, never, true, never>;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=editor-host.directive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-host.directive.d.ts","sourceRoot":"","sources":["../../../../src/lib/internal/editor-host/editor-host.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,SAAS,EACd,KAAK,MAAM,EAEZ,MAAM,eAAe,CAAC;AASvB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAC;;AAgB5F;;;;;;;;;;;GAWG;AACH,qBAmBa,iCAAkC,YAAW,MAAM,EAAE,SAAS;IACjD,UAAU,EAAG,wBAAwB,CAAC;IACrD,SAAS,UAAQ;IAE1B,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAkD;IACrE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqB;IAC9C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAkB;IACvC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAuB;IAEhD,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,WAAW,CAAK;IACxB,OAAO,CAAC,eAAe,CAAM;IAC7B,OAAO,CAAC,aAAa,CAAM;IAC3B,OAAO,CAAC,cAAc,CAAuB;IAE7C,OAAO,CAAC,yBAAyB,CAAC,CAAa;IAC/C,OAAO,CAAC,mBAAmB,CAAC,CAAyB;IAErD,QAAQ,IAAI,IAAI;IA8BhB,WAAW,IAAI,IAAI;IAanB,kBAAkB,IAAI,IAAI;IAI1B,gBAAgB,IAAI,IAAI;IAKxB,OAAO,IAAI,IAAI;IAMf,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI;IAIrC,OAAO,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IAoBpC,OAAO,IAAI,IAAI;IAIf,MAAM,IAAI,IAAI;IAMd,OAAO,CAAC,SAAS;IASjB,OAAO,CAAC,6BAA6B;IA4BrC,OAAO,CAAC,uBAAuB;IAsB/B,OAAO,CAAC,qBAAqB;yCAzKlB,iCAAiC;2CAAjC,iCAAiC;CA6M7C"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { EventEmitter } from "@angular/core";
|
|
2
|
+
import type { Suggestion } from "@magicx-eng/ai-autocomplete-vanilla";
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* Internal pill list used by both the dropdown and Tier 1's inline pillbar.
|
|
6
|
+
* Mirrors `packages/react/src/components/PillList.tsx` one-for-one — including
|
|
7
|
+
* the per-index opacity ramp (0.4 / 0.3 / 0.15) and the skeleton-loading
|
|
8
|
+
* fallback that preserves layout while the next fetch is in flight.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare class PillListComponent {
|
|
13
|
+
pills: Suggestion[];
|
|
14
|
+
activePillIndex: number;
|
|
15
|
+
rounded: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* When true, pills become non-interactive shimmering skeletons. Real pills
|
|
18
|
+
* (with their text) are rendered when provided so widths/positions match
|
|
19
|
+
* the previous state; with no pills, fixed-width fallback placeholders are
|
|
20
|
+
* rendered instead.
|
|
21
|
+
*/
|
|
22
|
+
loading: boolean;
|
|
23
|
+
readonly selectPill: EventEmitter<number>;
|
|
24
|
+
/** Fallback widths when loading with zero cached pills (matches React). */
|
|
25
|
+
readonly fallbackSkeletonWidths: number[];
|
|
26
|
+
/** Per-index opacity ramp — mirrors PillList.tsx `getPillOpacity`. */
|
|
27
|
+
pillOpacity(index: number): number;
|
|
28
|
+
trackByType: (_: number, pill: Suggestion) => string;
|
|
29
|
+
trackByWidth: (_: number, w: number) => number;
|
|
30
|
+
onPillClick(index: number): void;
|
|
31
|
+
onPillMouseDown(event: Event): void;
|
|
32
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<PillListComponent, never>;
|
|
33
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<PillListComponent, "aia-pill-list", never, { "pills": "pills"; "activePillIndex": "activePillIndex"; "rounded": "rounded"; "loading": "loading"; }, { "selectPill": "selectPill"; }, never, never, true, never>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=pill-list.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pill-list.component.d.ts","sourceRoot":"","sources":["../../../../src/lib/internal/pill-list/pill-list.component.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,YAAY,EAIb,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;;AAEtE;;;;;;;GAOG;AACH,qBASa,iBAAiB;IACnB,KAAK,EAAE,UAAU,EAAE,CAAM;IACzB,eAAe,SAAK;IACpB,OAAO,UAAS;IACzB;;;;;OAKG;IACM,OAAO,UAAS;IAEf,QAAQ,CAAC,UAAU,uBAA8B;IAE3D,2EAA2E;IAC3E,QAAQ,CAAC,sBAAsB,WAAa;IAE5C,sEAAsE;IACtE,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAMlC,WAAW,MAAO,MAAM,QAAQ,UAAU,KAAG,MAAM,CAAc;IACjE,YAAY,MAAO,MAAM,KAAK,MAAM,KAAG,MAAM,CAAM;IAEnD,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKhC,eAAe,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;yCAhCxB,iBAAiB;2CAAjB,iBAAiB;CAoC7B"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type AfterViewInit, type ElementRef, EventEmitter, type OnChanges, type OnDestroy } from "@angular/core";
|
|
2
|
+
import type { SuggestionOption } from "@magicx-eng/ai-autocomplete-vanilla";
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* Internal scrollable grid of suggestion options. Mirrors
|
|
6
|
+
* `packages/react/src/components/SuggestionGrid.tsx` — including the bottom
|
|
7
|
+
* fade overlay that appears when there's vertical overflow, driven by a
|
|
8
|
+
* ResizeObserver + scroll listener. ResizeObserver runs outside Angular's
|
|
9
|
+
* zone (§16.1) so high-frequency layout events don't trip change detection.
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare class SuggestionGridComponent implements AfterViewInit, OnChanges, OnDestroy {
|
|
14
|
+
options: SuggestionOption[];
|
|
15
|
+
activeIndex: number;
|
|
16
|
+
listboxId: string;
|
|
17
|
+
loading: boolean;
|
|
18
|
+
readonly select: EventEmitter<SuggestionOption>;
|
|
19
|
+
readonly highlight: EventEmitter<number>;
|
|
20
|
+
gridRef?: ElementRef<HTMLDivElement>;
|
|
21
|
+
hasBottomOverflow: boolean;
|
|
22
|
+
private readonly zone;
|
|
23
|
+
private readonly cdr;
|
|
24
|
+
private resizeObserver?;
|
|
25
|
+
private scrollListener?;
|
|
26
|
+
ngAfterViewInit(): void;
|
|
27
|
+
ngOnChanges(): void;
|
|
28
|
+
ngOnDestroy(): void;
|
|
29
|
+
trackByOptionText: (_: number, opt: SuggestionOption) => string;
|
|
30
|
+
onSelectItem(option: SuggestionOption): void;
|
|
31
|
+
onHighlightItem(index: number): void;
|
|
32
|
+
private bindOverflowTracking;
|
|
33
|
+
private measureOverflow;
|
|
34
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SuggestionGridComponent, never>;
|
|
35
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<SuggestionGridComponent, "aia-suggestion-grid", never, { "options": "options"; "activeIndex": "activeIndex"; "listboxId": "listboxId"; "loading": "loading"; }, { "select": "select"; "highlight": "highlight"; }, never, never, true, never>;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=suggestion-grid.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suggestion-grid.component.d.ts","sourceRoot":"","sources":["../../../../src/lib/internal/suggestion-grid/suggestion-grid.component.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,aAAa,EAIlB,KAAK,UAAU,EACf,YAAY,EAIZ,KAAK,SAAS,EACd,KAAK,SAAS,EAIf,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;;AAG5E;;;;;;;;GAQG;AACH,qBASa,uBAAwB,YAAW,aAAa,EAAE,SAAS,EAAE,SAAS;IACxE,OAAO,EAAE,gBAAgB,EAAE,CAAM;IACjC,WAAW,SAAM;IACjB,SAAS,SAAM;IACf,OAAO,UAAS;IAEf,QAAQ,CAAC,MAAM,iCAAwC;IACvD,QAAQ,CAAC,SAAS,uBAA8B;IAEpB,OAAO,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,CAAC;IAE3E,iBAAiB,UAAS;IAE1B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAkB;IACvC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAA6B;IACjD,OAAO,CAAC,cAAc,CAAC,CAAiB;IACxC,OAAO,CAAC,cAAc,CAAC,CAAa;IAEpC,eAAe,IAAI,IAAI;IAKvB,WAAW,IAAI,IAAI;IAOnB,WAAW,IAAI,IAAI;IAOnB,iBAAiB,MAAO,MAAM,OAAO,gBAAgB,KAAG,MAAM,CAAa;IAE3E,YAAY,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI;IAI5C,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAIpC,OAAO,CAAC,oBAAoB;IAe5B,OAAO,CAAC,eAAe;yCA9DZ,uBAAuB;2CAAvB,uBAAuB;CAyEnC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { EventEmitter, type OnDestroy } from "@angular/core";
|
|
2
|
+
import type { SuggestionOption } from "@magicx-eng/ai-autocomplete-vanilla";
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* Internal single-option cell used inside the suggestion grid. Mirrors
|
|
6
|
+
* `packages/react/src/components/SuggestionItem.tsx`. Handles:
|
|
7
|
+
*
|
|
8
|
+
* - Tappable vs non-tappable cursor + hover styling
|
|
9
|
+
* - Pressed-state streak animation (500ms, single-flight)
|
|
10
|
+
* - Keyboard activation (Enter/Space)
|
|
11
|
+
* - ARIA `role="option"` + `aria-selected` for the listbox pattern
|
|
12
|
+
* - Loading skeleton when `loading=true`
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export declare class SuggestionItemComponent implements OnDestroy {
|
|
17
|
+
option: SuggestionOption;
|
|
18
|
+
isHighlighted: boolean;
|
|
19
|
+
id: string;
|
|
20
|
+
loading: boolean;
|
|
21
|
+
readonly select: EventEmitter<SuggestionOption>;
|
|
22
|
+
readonly highlight: EventEmitter<void>;
|
|
23
|
+
pressed: boolean;
|
|
24
|
+
private readonly cdr;
|
|
25
|
+
private pressedTimer;
|
|
26
|
+
ngOnDestroy(): void;
|
|
27
|
+
onSelect(): void;
|
|
28
|
+
onMouseEnter(): void;
|
|
29
|
+
onKeyDown(event: KeyboardEvent): void;
|
|
30
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SuggestionItemComponent, never>;
|
|
31
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<SuggestionItemComponent, "aia-suggestion-item", never, { "option": "option"; "isHighlighted": "isHighlighted"; "id": "id"; "loading": "loading"; }, { "select": "select"; "highlight": "highlight"; }, never, never, true, never>;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=suggestion-item.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suggestion-item.component.d.ts","sourceRoot":"","sources":["../../../../src/lib/internal/suggestion-item/suggestion-item.component.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,YAAY,EAGZ,KAAK,SAAS,EAGf,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;;AAE5E;;;;;;;;;;;GAWG;AACH,qBASa,uBAAwB,YAAW,SAAS;IAC9C,MAAM,EAAG,gBAAgB,CAAC;IAC1B,aAAa,UAAS;IACtB,EAAE,SAAM;IACR,OAAO,UAAS;IAEf,QAAQ,CAAC,MAAM,iCAAwC;IACvD,QAAQ,CAAC,SAAS,qBAA4B;IAExD,OAAO,UAAS;IAEhB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAA6B;IACjD,OAAO,CAAC,YAAY,CAA4C;IAEhE,WAAW,IAAI,IAAI;IAInB,QAAQ,IAAI,IAAI;IAYhB,YAAY,IAAI,IAAI;IAKpB,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI;yCAnC1B,uBAAuB;2CAAvB,uBAAuB;CA0CnC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import type { APIConfig, AutocompleteResult, CompletedParamState, OptionOverrides, Segment, Suggestion } from "@magicx-eng/ai-autocomplete-vanilla";
|
|
2
|
+
/**
|
|
3
|
+
* Construction-time options for {@link AIAutocompleteController}.
|
|
4
|
+
*
|
|
5
|
+
* Mirrors the props the React `useAIAutocomplete()` hook accepts, minus the
|
|
6
|
+
* fields that only make sense for a React component shell (`columns` is here;
|
|
7
|
+
* `autoFocus`, `className`, `pillPlacement`, etc. live on the Tier 1
|
|
8
|
+
* `<ai-autocomplete>` component).
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export interface AIAutocompleteControllerOptions {
|
|
13
|
+
/** Runtime API configuration (apiKey, endpoint, etc.). */
|
|
14
|
+
apiConfig?: APIConfig;
|
|
15
|
+
/** Per-suggestion-type client-side option overrides. */
|
|
16
|
+
optionOverrides?: OptionOverrides;
|
|
17
|
+
/** When true, completed params' literal text is omitted from API requests. */
|
|
18
|
+
maskCompletedText?: boolean;
|
|
19
|
+
/** Number of columns in the dropdown grid. Default: 2. */
|
|
20
|
+
columns?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Where the dropdown opens relative to the input. Default: "below".
|
|
23
|
+
*
|
|
24
|
+
* Read by the keyboard controller to decide which vertical-arrow key opens
|
|
25
|
+
* the dropdown from the input — ArrowDown when the dropdown is below,
|
|
26
|
+
* ArrowUp when it's above.
|
|
27
|
+
*/
|
|
28
|
+
optionsPosition?: "above" | "below";
|
|
29
|
+
/**
|
|
30
|
+
* When the dropdown appears. "auto" (default) shows when options are
|
|
31
|
+
* available; "manual" shows only on pill tap; "hidden" never shows.
|
|
32
|
+
*/
|
|
33
|
+
dropdownTrigger?: "auto" | "manual" | "hidden";
|
|
34
|
+
/** When true (default), the dropdown closes if the input loses focus. */
|
|
35
|
+
closeDropdownOnBlur?: boolean;
|
|
36
|
+
/** When true (default), non-tappable options render alongside tappable ones. */
|
|
37
|
+
showNonTappableOptions?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Telemetry surface identifier. Set automatically to "full-sdk" by the
|
|
40
|
+
* Tier 1 `<ai-autocomplete>` component. Defaults to "headless-sdk".
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
source?: "full-sdk" | "headless-sdk";
|
|
44
|
+
/** Called when the user submits (Enter key or `submit()` action). */
|
|
45
|
+
onSubmit?: (result: AutocompleteResult) => void;
|
|
46
|
+
/** Called when a fetch fails. */
|
|
47
|
+
onError?: (error: Error) => void;
|
|
48
|
+
/** Called when the editor text changes (controlled-mode signal). */
|
|
49
|
+
onChange?: (text: string) => void;
|
|
50
|
+
/** Called when completed params change (controlled-mode signal). */
|
|
51
|
+
onParamsChange?: (params: CompletedParamState[]) => void;
|
|
52
|
+
/** Called when the input gains focus. */
|
|
53
|
+
onFocus?: () => void;
|
|
54
|
+
/** Called when the input loses focus. */
|
|
55
|
+
onBlur?: () => void;
|
|
56
|
+
/** Initial controlled text value. */
|
|
57
|
+
value?: string;
|
|
58
|
+
/** Initial controlled completed params. */
|
|
59
|
+
completedParams?: CompletedParamState[];
|
|
60
|
+
/**
|
|
61
|
+
* Caret-set callback. Invoked by the core when re-edit / Backspace flows
|
|
62
|
+
* need the editor caret parked at a specific plain-text offset. The Tier 1
|
|
63
|
+
* `<ai-autocomplete>` component wires this from its editor host; headless
|
|
64
|
+
* consumers can leave it unset.
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
67
|
+
setCursor?: (offset: number) => void;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Subset of {@link AIAutocompleteControllerOptions} that can be changed after
|
|
71
|
+
* construction. Excludes event callbacks (those are registered once at
|
|
72
|
+
* construction — see TDB §3 / vanilla `CoreUpdateOptions`).
|
|
73
|
+
*
|
|
74
|
+
* @public
|
|
75
|
+
*/
|
|
76
|
+
export type AIAutocompleteControllerUpdate = Partial<Omit<AIAutocompleteControllerOptions, "onSubmit" | "onError" | "onChange" | "onParamsChange" | "onFocus" | "onBlur" | "setCursor">>;
|
|
77
|
+
/**
|
|
78
|
+
* Snapshot of the controller's reactive state. Each field is also exposed as
|
|
79
|
+
* a stand-alone observable on the controller (e.g. `controller.text$`).
|
|
80
|
+
*
|
|
81
|
+
* `suggestionPills` mirrors React's `suggestionPills` — the actionable
|
|
82
|
+
* subset of `suggestions` ready for pill rendering. `isLoading` is the
|
|
83
|
+
* UI-visible loading flag (suppressed during the post-select streak
|
|
84
|
+
* animation and during re-edit, where cached options stay visible).
|
|
85
|
+
*
|
|
86
|
+
* @public
|
|
87
|
+
*/
|
|
88
|
+
export interface AIAutocompleteControllerState {
|
|
89
|
+
text: string;
|
|
90
|
+
completedParams: CompletedParamState[];
|
|
91
|
+
suggestionPills: Suggestion[];
|
|
92
|
+
segments: Segment[];
|
|
93
|
+
newParamId: string | null;
|
|
94
|
+
suggestions: Suggestion[];
|
|
95
|
+
activeIndex: number;
|
|
96
|
+
isLoading: boolean;
|
|
97
|
+
isReady: boolean;
|
|
98
|
+
isFocused: boolean;
|
|
99
|
+
isDropdownOpen: boolean;
|
|
100
|
+
placeholderText: string;
|
|
101
|
+
error: Error | null;
|
|
102
|
+
editingParam: CompletedParamState | null;
|
|
103
|
+
editingAnchor: number | null;
|
|
104
|
+
caretOffset: number | null;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Composite state shape for the dropdown view layer. Tier 2 consumers bind
|
|
108
|
+
* the dropdown component to this snapshot; Tier 1 uses the same shape
|
|
109
|
+
* internally.
|
|
110
|
+
*
|
|
111
|
+
* @public
|
|
112
|
+
*/
|
|
113
|
+
export interface AIAutocompleteDropdownState {
|
|
114
|
+
/** Active suggestion + filtered options to render in the grid. */
|
|
115
|
+
suggestions: Suggestion[];
|
|
116
|
+
/** Currently highlighted option index. -1 when none. */
|
|
117
|
+
activeIndex: number;
|
|
118
|
+
/** Whether the dropdown should be visible. */
|
|
119
|
+
isOpen: boolean;
|
|
120
|
+
/** Pills to render in the dropdown's pillbar (re-edit pill or all suggestion pills). */
|
|
121
|
+
pills: Suggestion[];
|
|
122
|
+
/** True when the dropdown should render its loading skeleton. */
|
|
123
|
+
isLoading: boolean;
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/shared/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,OAAO,EACP,UAAU,EACX,MAA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"names":[],"mappings":"AAAA;;GAEG;;AAEH,cAAc,cAAc,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@magicx-eng/ai-autocomplete-angular",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "AI Autocomplete Angular SDK — guided autocomplete with pill-based input and dropdown suggestions",
|
|
5
|
+
"module": "fesm2015/magicx-eng-ai-autocomplete-angular.mjs",
|
|
6
|
+
"es2020": "fesm2020/magicx-eng-ai-autocomplete-angular.mjs",
|
|
7
|
+
"esm2020": "esm2020/magicx-eng-ai-autocomplete-angular.mjs",
|
|
8
|
+
"fesm2020": "fesm2020/magicx-eng-ai-autocomplete-angular.mjs",
|
|
9
|
+
"fesm2015": "fesm2015/magicx-eng-ai-autocomplete-angular.mjs",
|
|
10
|
+
"typings": "index.d.ts",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public",
|
|
14
|
+
"directory": "dist"
|
|
15
|
+
},
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"@angular/common": ">=15.0.0 <18.0.0",
|
|
18
|
+
"@angular/core": ">=15.0.0 <18.0.0",
|
|
19
|
+
"@angular/forms": ">=15.0.0 <18.0.0",
|
|
20
|
+
"rxjs": ">=7.0.0"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"tslib": "^2.3.0",
|
|
24
|
+
"@magicx-eng/ai-autocomplete-vanilla": "0.2.0"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"angular",
|
|
28
|
+
"autocomplete",
|
|
29
|
+
"ai",
|
|
30
|
+
"typescript"
|
|
31
|
+
],
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"exports": {
|
|
34
|
+
"./package.json": {
|
|
35
|
+
"default": "./package.json"
|
|
36
|
+
},
|
|
37
|
+
".": {
|
|
38
|
+
"types": "./index.d.ts",
|
|
39
|
+
"esm2020": "./esm2020/magicx-eng-ai-autocomplete-angular.mjs",
|
|
40
|
+
"es2020": "./fesm2020/magicx-eng-ai-autocomplete-angular.mjs",
|
|
41
|
+
"es2015": "./fesm2015/magicx-eng-ai-autocomplete-angular.mjs",
|
|
42
|
+
"node": "./fesm2015/magicx-eng-ai-autocomplete-angular.mjs",
|
|
43
|
+
"default": "./fesm2020/magicx-eng-ai-autocomplete-angular.mjs"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
package/public-api.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public API surface for @magicx-eng/ai-autocomplete-angular.
|
|
3
|
+
*
|
|
4
|
+
* Populated incrementally as features land — see TDB.md §6.6 for the full
|
|
5
|
+
* planned export list. Only symbols re-exported here are considered part of
|
|
6
|
+
* the package's public contract (TDB §19.2).
|
|
7
|
+
*/
|
|
8
|
+
export type { AccessTokenConfig, AccessTokenResult, APIConfig, APIKeyConfig, AppearanceMode, AutocompleteResult, CompletedParam, CompletedParamState, OptionOverrides, Segment, Suggestion, SuggestionOption, TaskKind, } from "@magicx-eng/ai-autocomplete-vanilla";
|
|
9
|
+
export { AIAutocompleteComponent } from "./lib/ai-autocomplete";
|
|
10
|
+
export { AIAutocompleteModule } from "./lib/ai-autocomplete.module";
|
|
11
|
+
export { AIAutocompleteDropdownComponent } from "./lib/ai-autocomplete-dropdown";
|
|
12
|
+
export { AIAutocompleteController } from "./lib/controller";
|
|
13
|
+
export { AIAutocompleteInputDirective } from "./lib/input";
|
|
14
|
+
export type { AIAutocompleteControllerOptions, AIAutocompleteControllerState, AIAutocompleteControllerUpdate, AIAutocompleteDropdownState, } from "./lib/shared/types";
|
|
15
|
+
//# sourceMappingURL=public-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../src/public-api.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,SAAS,EACT,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,OAAO,EACP,UAAU,EACV,gBAAgB,EAChB,QAAQ,GACT,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE,OAAO,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AAEjF,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAE3D,YAAY,EACV,+BAA+B,EAC/B,6BAA6B,EAC7B,8BAA8B,EAC9B,2BAA2B,GAC5B,MAAM,oBAAoB,CAAC"}
|