@magicx-eng/ai-autocomplete-vanilla 0.9.0 → 0.10.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/dist/index.d.mts CHANGED
@@ -563,6 +563,14 @@ declare class AIAutocomplete {
563
563
  private setupContainer;
564
564
  private buildAndRenderFull;
565
565
  private buildAndRenderDropdown;
566
+ /**
567
+ * Re-render when the viewport crosses the mobile breakpoint, so the options
568
+ * grid's mobile/web column policy (see computeOptionsGridLayout) updates live
569
+ * while the dropdown is open and otherwise idle. Mirrors the matchMedia
570
+ * listener in the React grid and the window:resize HostListener in Angular.
571
+ * The unsubscribe is registered for cleanup in destroy().
572
+ */
573
+ private subscribeViewportBreakpoint;
566
574
  /** Batched render subscriber — coalesces multiple store.set calls into one DOM update. */
567
575
  private subscribeBatchedRender;
568
576
  /** Auto-clear newParamId after shimmer animation. */
@@ -599,6 +607,42 @@ declare class AIAutocomplete {
599
607
  private maybePromoteExactMatch;
600
608
  }
601
609
 
610
+ /**
611
+ * Rows/columns policy for the dropdown's options grid.
612
+ *
613
+ * All three packages render the same grid and must agree on the policy, so it
614
+ * lives here (in the core) and is imported by the React and Angular shells
615
+ * rather than reimplemented per package — the way the rest of the shared logic
616
+ * works. Duplicating it left the row-height and footer-band constants free to
617
+ * drift three ways with three green suites.
618
+ */
619
+ /** The viewport width the grid treats as "phone" — same breakpoint as the mobile footer. */
620
+ declare const OPTIONS_GRID_MOBILE_QUERY = "(max-width: 768px)";
621
+ interface OptionsGridLayout {
622
+ /** Column count for `grid-template-columns`. */
623
+ cols: number;
624
+ /** Rows visible before the list scrolls. */
625
+ rows: number;
626
+ /** Value for `--aia-grid-max-height` — caps the scroll box at `rows` rows. */
627
+ maxHeight: string;
628
+ }
629
+ /**
630
+ * - Mobile: one column, five rows visible (scroll past five).
631
+ * - Web: one column, four rows visible by default — but when there are exactly
632
+ * five or six options, two balanced columns (so 5/6 fit without scrolling).
633
+ * Columns fill row-major, so the two columns end up 3/2 (five) or 3/3 (six).
634
+ */
635
+ declare function computeOptionsGridLayout(count: number, isMobile: boolean): OptionsGridLayout;
636
+ /**
637
+ * `grid-template-columns` for a fixed column count. Space-separated
638
+ * `minmax(0,1fr)` tracks (no `repeat()`, no inner spaces) so rows fill
639
+ * row-major — which the keyboard controller assumes — and the track count reads
640
+ * back correctly wherever computed styles aren't fully resolved.
641
+ */
642
+ declare function optionsGridTemplateColumns(cols: number): string;
643
+ /** Whether the current viewport is phone-width. `false` when there's no DOM. */
644
+ declare function isOptionsGridMobileViewport(): boolean;
645
+
602
646
  /**
603
647
  * Plain-text caret utilities for contentEditable elements.
604
648
  *
@@ -764,4 +808,4 @@ declare function withSkippedParams(completed: CompletedParam[], skipped: Skipped
764
808
  */
765
809
  declare function buildSubmitResult(text: string, completedParams: CompletedParamState[], skippedParams?: SkippedParamState[]): AutocompleteResult;
766
810
 
767
- export { AIAutocomplete, type APIConfig, type APIKeyConfig, ATTRIBUTION_URL, type AccessTokenConfig, type AccessTokenResult, type AppearanceMode, type AutocompleteRequest, type AutocompleteResponse, type AutocompleteResult, type CompletedParam, type CompletedParamState, type CoreOptions, type CoreState, type IdentifiedParam, type IdentifiedParamState, type InputItem, ModeController, type OptionOverrides, type Product, type ProductsConfig, type RecentlySuggested, type RenderMode, SKIPPED_PARAM_TEXT, type Segment, type SkippedParamState, type Store, type Suggestion, type SuggestionOption, type TaskKind, buildAttributionUrl, buildQuery, buildSubmitResult, createStore, cursorIsAtEnd, extractPlainText, getCursorOffset, getFooterHint, plainTextLength, previousGraphemeBoundary, renderEditableContent, setCursorOffset, withSkippedParams };
811
+ export { AIAutocomplete, type APIConfig, type APIKeyConfig, ATTRIBUTION_URL, type AccessTokenConfig, type AccessTokenResult, type AppearanceMode, type AutocompleteRequest, type AutocompleteResponse, type AutocompleteResult, type CompletedParam, type CompletedParamState, type CoreOptions, type CoreState, type IdentifiedParam, type IdentifiedParamState, type InputItem, ModeController, OPTIONS_GRID_MOBILE_QUERY, type OptionOverrides, type OptionsGridLayout, type Product, type ProductsConfig, type RecentlySuggested, type RenderMode, SKIPPED_PARAM_TEXT, type Segment, type SkippedParamState, type Store, type Suggestion, type SuggestionOption, type TaskKind, buildAttributionUrl, buildQuery, buildSubmitResult, computeOptionsGridLayout, createStore, cursorIsAtEnd, extractPlainText, getCursorOffset, getFooterHint, isOptionsGridMobileViewport, optionsGridTemplateColumns, plainTextLength, previousGraphemeBoundary, renderEditableContent, setCursorOffset, withSkippedParams };
package/dist/index.d.ts CHANGED
@@ -563,6 +563,14 @@ declare class AIAutocomplete {
563
563
  private setupContainer;
564
564
  private buildAndRenderFull;
565
565
  private buildAndRenderDropdown;
566
+ /**
567
+ * Re-render when the viewport crosses the mobile breakpoint, so the options
568
+ * grid's mobile/web column policy (see computeOptionsGridLayout) updates live
569
+ * while the dropdown is open and otherwise idle. Mirrors the matchMedia
570
+ * listener in the React grid and the window:resize HostListener in Angular.
571
+ * The unsubscribe is registered for cleanup in destroy().
572
+ */
573
+ private subscribeViewportBreakpoint;
566
574
  /** Batched render subscriber — coalesces multiple store.set calls into one DOM update. */
567
575
  private subscribeBatchedRender;
568
576
  /** Auto-clear newParamId after shimmer animation. */
@@ -599,6 +607,42 @@ declare class AIAutocomplete {
599
607
  private maybePromoteExactMatch;
600
608
  }
601
609
 
610
+ /**
611
+ * Rows/columns policy for the dropdown's options grid.
612
+ *
613
+ * All three packages render the same grid and must agree on the policy, so it
614
+ * lives here (in the core) and is imported by the React and Angular shells
615
+ * rather than reimplemented per package — the way the rest of the shared logic
616
+ * works. Duplicating it left the row-height and footer-band constants free to
617
+ * drift three ways with three green suites.
618
+ */
619
+ /** The viewport width the grid treats as "phone" — same breakpoint as the mobile footer. */
620
+ declare const OPTIONS_GRID_MOBILE_QUERY = "(max-width: 768px)";
621
+ interface OptionsGridLayout {
622
+ /** Column count for `grid-template-columns`. */
623
+ cols: number;
624
+ /** Rows visible before the list scrolls. */
625
+ rows: number;
626
+ /** Value for `--aia-grid-max-height` — caps the scroll box at `rows` rows. */
627
+ maxHeight: string;
628
+ }
629
+ /**
630
+ * - Mobile: one column, five rows visible (scroll past five).
631
+ * - Web: one column, four rows visible by default — but when there are exactly
632
+ * five or six options, two balanced columns (so 5/6 fit without scrolling).
633
+ * Columns fill row-major, so the two columns end up 3/2 (five) or 3/3 (six).
634
+ */
635
+ declare function computeOptionsGridLayout(count: number, isMobile: boolean): OptionsGridLayout;
636
+ /**
637
+ * `grid-template-columns` for a fixed column count. Space-separated
638
+ * `minmax(0,1fr)` tracks (no `repeat()`, no inner spaces) so rows fill
639
+ * row-major — which the keyboard controller assumes — and the track count reads
640
+ * back correctly wherever computed styles aren't fully resolved.
641
+ */
642
+ declare function optionsGridTemplateColumns(cols: number): string;
643
+ /** Whether the current viewport is phone-width. `false` when there's no DOM. */
644
+ declare function isOptionsGridMobileViewport(): boolean;
645
+
602
646
  /**
603
647
  * Plain-text caret utilities for contentEditable elements.
604
648
  *
@@ -764,4 +808,4 @@ declare function withSkippedParams(completed: CompletedParam[], skipped: Skipped
764
808
  */
765
809
  declare function buildSubmitResult(text: string, completedParams: CompletedParamState[], skippedParams?: SkippedParamState[]): AutocompleteResult;
766
810
 
767
- export { AIAutocomplete, type APIConfig, type APIKeyConfig, ATTRIBUTION_URL, type AccessTokenConfig, type AccessTokenResult, type AppearanceMode, type AutocompleteRequest, type AutocompleteResponse, type AutocompleteResult, type CompletedParam, type CompletedParamState, type CoreOptions, type CoreState, type IdentifiedParam, type IdentifiedParamState, type InputItem, ModeController, type OptionOverrides, type Product, type ProductsConfig, type RecentlySuggested, type RenderMode, SKIPPED_PARAM_TEXT, type Segment, type SkippedParamState, type Store, type Suggestion, type SuggestionOption, type TaskKind, buildAttributionUrl, buildQuery, buildSubmitResult, createStore, cursorIsAtEnd, extractPlainText, getCursorOffset, getFooterHint, plainTextLength, previousGraphemeBoundary, renderEditableContent, setCursorOffset, withSkippedParams };
811
+ export { AIAutocomplete, type APIConfig, type APIKeyConfig, ATTRIBUTION_URL, type AccessTokenConfig, type AccessTokenResult, type AppearanceMode, type AutocompleteRequest, type AutocompleteResponse, type AutocompleteResult, type CompletedParam, type CompletedParamState, type CoreOptions, type CoreState, type IdentifiedParam, type IdentifiedParamState, type InputItem, ModeController, OPTIONS_GRID_MOBILE_QUERY, type OptionOverrides, type OptionsGridLayout, type Product, type ProductsConfig, type RecentlySuggested, type RenderMode, SKIPPED_PARAM_TEXT, type Segment, type SkippedParamState, type Store, type Suggestion, type SuggestionOption, type TaskKind, buildAttributionUrl, buildQuery, buildSubmitResult, computeOptionsGridLayout, createStore, cursorIsAtEnd, extractPlainText, getCursorOffset, getFooterHint, isOptionsGridMobileViewport, optionsGridTemplateColumns, plainTextLength, previousGraphemeBoundary, renderEditableContent, setCursorOffset, withSkippedParams };