import { type AfterViewInit, type ElementRef, EventEmitter, type OnChanges, type OnDestroy, type OnInit, type SimpleChanges, type TemplateRef } from "@angular/core"; import { type ControlValueAccessor } from "@angular/forms"; import { type APIConfig, type AppearanceMode, type AutocompleteResult, type CompletedParamState, type CoreOptions, type OptionOverrides, type Product, type ProductImageFallback, type ProductsConfig, type ProductsLayout } from "@magicx-eng/ai-autocomplete-vanilla"; import { AIAutocompleteController } from "../controller/ai-autocomplete.controller"; import * as i0 from "@angular/core"; /** * Tier 1 component — ``. The Angular equivalent of React's * ``. Owns the contentEditable editor, inline pills, mode * controller, submit button slot, and an embedded * {@link AIAutocompleteController} that drives the dropdown. * * @public */ export declare class AIAutocompleteComponent implements OnInit, AfterViewInit, OnChanges, OnDestroy, ControlValueAccessor { apiConfig?: APIConfig; /** * Optional user context. Include whatever you know about the user — a * profile, preferences, workspace, anything — to personalize suggested * parameters and options to them. Bind a stable reference; the same swap * rule that applies to `apiConfig` applies here. */ additionalContext?: Record; /** * BCP 47 language tag (e.g. `"es"`), sent with every suggestion request. * Default: the browser language (`navigator.language`), else `"en-US"`. */ language?: string; /** * Your product id. When set, what the dropdown offers before anything is * typed is read from a cacheable URL for your product, with no credential, * instead of a suggestion request; it falls back to a suggestion request * when it cannot be read. */ productId?: string; /** * Stable id for this visitor, kept by the host across page loads. Rides on * telemetry events so searches can be joined to what the visitor does * afterwards. Must be a UUID v4; omit to send none. A function is called * only once the server has funnel telemetry on. */ visitorId?: string | (() => string | undefined); optionOverrides?: OptionOverrides; maskCompletedText: boolean; columns?: number; /** Where unfilled pills render. Default: "dropdown". */ pillPlacement: "inline" | "dropdown" | "hidden"; /** Color mode. "auto" follows prefers-color-scheme. Default: "auto". */ mode: AppearanceMode; optionsPosition: "above" | "below"; animations: boolean; dropdownTrigger?: "auto" | "manual" | "hidden"; closeDropdownOnBlur?: boolean; showNonTappableOptions?: boolean; /** * When true (default), the dropdown's pill bar ends in a small "skip" button * that dismisses the active pill — same action as pressing → at the end of * the input. Set to false to hide it. When pills render elsewhere * (`pillPlacement: "inline"` / `"hidden"`) the bar renders as a skip-only * row holding just the button. Hidden while the input is empty — it appears * alongside the footer's "→ to skip" hint once the user has typed. */ showSkipButton: boolean; /** When true (default), an option that carries an `icon_svg` draws its icon before its text in the dropdown. Set to false to render option rows as text only. */ showOptionIcons: boolean; /** When true (default), an option that carries an `image_url` draws it as a square thumbnail before its text in the dropdown (in place of its `icon_svg`). Set to false to render option rows without pictures. */ showOptionImages: boolean; /** When true (default), an option that carries an `item_count` shows it as a muted label at the row's trailing edge ("12 items"). Set to false to hide the counts. */ showOptionCounts: boolean; /** * How the product strip lays its cards out. `"row"` (the default) is a * horizontally scrolling shelf of cards. `"list"` stacks the same cards as * full-width rows — thumbnail on the left, title, vendor and price on the * right — for results that read as a list (courses, listings, documents) * rather than products on a shelf; the column scrolls vertically inside * `--aia-product-list-max-height`. */ productsLayout: ProductsLayout; /** Missing/failed image fallback. Style initials with `[data-aia-product-initial]`. */ productImageFallback: ProductImageFallback; /** When true (default), a completed chip in the input draws the icon of the option that answered it. Set to false to render chips as text only. */ showChipIcons: boolean; /** When true (default), a completed chip in the input draws the picture (`image_url`) of the option that answered it, in place of its icon. Set to false to render chips without pictures. */ showChipImages: boolean; /** Focus the editor on mount. Default: true. */ autoFocus: boolean; /** Controlled-mode text value. */ value?: string; /** Controlled-mode completed params. */ completedParams?: CompletedParamState[]; /** * When true (default), the dropdown renders a horizontal row of product * cards below the options grid whenever it has products to show: by default * the items the `/suggest` response reports as matching the query, or the * results of a custom `products` search. Set to false to render no strip * and run no custom search. */ showProducts: boolean; /** * Custom source for the product strip. Omit it and the strip shows the * items the `/suggest` response itself reports as matching the query, with * no extra request. Set it and the dropdown is fed by your own search * endpoint on the SDK's existing fetch cadence instead; the server's items * are then not rendered. * * Bind a stable reference (a component field, not an inline object literal): * a new object on each change-detection pass reads as a swapped integration * and clears the current cards — the same rule that already applies to * `apiConfig` and `optionOverrides`. */ products?: ProductsConfig; mapProducts?: CoreOptions["mapProducts"]; /** * Custom submit button. Pass a `` to replace the default arrow * button. Pass `null` to render no button. Default (`undefined`) renders * the built-in arrow. */ submitButton?: TemplateRef | null; /** * When true (default), the editor is cleared and a new session starts after * `submitted` emits — on Enter and on the submit button. Set to false to * leave the query in place: when the handler navigates away, a cleared field * flashes empty until the next page paints. Call `reset()` yourself when you * want a fresh session. */ resetOnSubmit: boolean; /** Called on Enter or submit-button click. */ readonly submitted: EventEmitter; /** * Fires after every successful suggestion round-trip with the structured * query as the SDK now understands it — the same `AutocompleteResult` shape * `submitted` carries, so you can mirror the query as it is built (a live * preview, a draft, analytics) without waiting for submit. Fires once per * applied response, including the initial request on init (an empty * result); never for a failed, aborted or superseded request. */ readonly resultChange: EventEmitter; readonly errored: EventEmitter; readonly valueChange: EventEmitter; readonly completedParamsChange: EventEmitter; readonly focused: EventEmitter; readonly blurred: EventEmitter; /** * Emitted when the user activates a product card. The SDK does not * navigate — you decide what a selection means. Modifier / middle clicks are * left to the browser (cmd-click still opens a tab) and don't emit. */ readonly productSelect: EventEmitter; containerRef: ElementRef; editorRef?: ElementRef; pillContainerRef?: ElementRef; controller: AIAutocompleteController; /** * Concrete light/dark value bound to `[attr.data-mode]`. Seeded in ngOnInit * so the attribute is present during SSR (where ModeController, gated behind * isPlatformBrowser in ngAfterViewInit, never runs). On the browser the * ModeController's resolve callback keeps this in sync — so its runtime * prefers-color-scheme updates and this binding always agree (no clobber). */ resolvedMode: "light" | "dark"; private modeController?; private resizeObserver?; private onChangeFn; private onTouchedFn; private pendingWriteValue; private readonly platformId; private readonly zone; private readonly cdr; ngOnInit(): void; ngAfterViewInit(): void; ngOnChanges(changes: SimpleChanges): void; ngOnDestroy(): void; /** Programmatically focus the editor. */ focus(): void; /** Programmatically blur the editor. */ blur(): void; /** * Runs mapProducts synchronously on the shown items again without a request. * Keeps the same cards while updating their content. * Does nothing without mapProducts or with a custom products integration. */ refreshProducts(): void; /** Clear all state, rotate session, and re-fetch. */ reset(): void; /** * Skip the active pill — same action as the dropdown's skip button / →. * Lets a consumer who hides the built-in button (`showSkipButton=false`) * drive skipping from their own UI. */ skipActivePill(): void; /** Switch color mode at runtime. */ setMode(mode: AppearanceMode): void; /** * 'default' → render the built-in arrow button. * 'custom' → project the consumer-supplied TemplateRef. * 'hidden' → no button. */ get submitButtonState(): "default" | "custom" | "hidden"; /** Narrowed accessor for *ngTemplateOutlet — never undefined. */ /** The default submit button's name, in the widget language. */ get submitLabel(): string; get customSubmitTemplate(): TemplateRef | null; get showInlinePills(): boolean; get showDropdownPills(): boolean; /** * `true` when there's something to submit — driven by current segments * and completed params. Read off the live editor via the controller state. */ canSubmit(state: { segments: { length: number; }; completedParams: { length: number; }; }): boolean; onWrapperClick(event: MouseEvent): void; onSubmitButtonClick(event: MouseEvent): void; onSubmitSlotClick(event: MouseEvent): void; onSelectPill(index: number): void; writeValue(value: string | null): void; registerOnChange(fn: (value: string) => void): void; registerOnTouched(fn: () => void): void; setDisabledState(_disabled: boolean): void; /** * Called by the controller's onSubmit callback (which fires from the * keyboard controller on Enter). Reads the live editor text — same trick * the React component uses — so the emitted query reflects whatever's in * the DOM right now, not a possibly-stale state snapshot. */ private handleSubmit; private handleSubmitFromUserAction; private measurePillWrap; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } //# sourceMappingURL=ai-autocomplete.component.d.ts.map