@magicx-eng/ai-autocomplete-vanilla 0.2.1 → 0.4.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
@@ -136,6 +136,12 @@ interface CoreInputState {
136
136
  * Set by selectOption / ReEditManager.selectOption, cleared by a timer.
137
137
  */
138
138
  inSelectionAnimation: boolean;
139
+ /**
140
+ * True once the user has pressed Tab to highlight a dropdown option. Drives
141
+ * the dropdown footer hint: "tab to select" before the first Tab, then
142
+ * "→ to skip" afterwards. Sticky until `reset()` clears it.
143
+ */
144
+ hasTabbedToHighlight: boolean;
139
145
  }
140
146
  /**
141
147
  * Derived fields recomputed from {@link CoreInputState} + {@link CoreOptions}.
@@ -148,6 +154,18 @@ interface CoreDerivedState {
148
154
  filteredOptions: SuggestionOption[];
149
155
  placeholderText: string;
150
156
  isDropdownOpen: boolean;
157
+ /**
158
+ * Whether the active (leading) pill should render in its `selected` state
159
+ * (full opacity) rather than the de-emphasized `first` tier. True when the
160
+ * dropdown is open AND a tappable option is highlighted (`activeDropdownIndex
161
+ * >= 0 && is_tappable`). This rule is uniform across all trigger modes:
162
+ * - `auto`: becomes true on keyboard nav / hover / pill tap.
163
+ * - `manual`: becomes true on pill tap — `setActivePill` opens the dropdown
164
+ * and auto-highlights the first tappable option; false if the pill has no
165
+ * tappable option.
166
+ * - `hidden`: always false (the dropdown never opens).
167
+ */
168
+ isActivePillSelected: boolean;
151
169
  }
152
170
  /**
153
171
  * Full state shape (inputs + derived) exposed to consumers via `getState()`
@@ -415,6 +433,24 @@ interface BuildQueryResult {
415
433
  */
416
434
  declare function buildQuery(text: string, completedParams: CompletedParamState[]): BuildQueryResult;
417
435
 
436
+ /**
437
+ * The dropdown footer's keyboard hint has four states, in priority order:
438
+ * 1. an option is highlighted → "enter to proceed" (Enter commits it);
439
+ * 2. otherwise, the input is empty → "tab to skip" — with nothing typed there's
440
+ * nothing to select, so Tab skips the active pill. This holds regardless of
441
+ * whether the user has tabbed to highlight yet;
442
+ * 3. otherwise, the user has tabbed to highlight at some point → "→ to skip"
443
+ * (the right arrow skips the active pill);
444
+ * 4. otherwise (fresh, with text) → "tab to select".
445
+ *
446
+ * Pure computation — no DOM access. Shared by the vanilla renderer and the
447
+ * React / Angular footer components so the wording can't drift between them.
448
+ */
449
+ declare function getFooterHint(hasTabbedToHighlight: boolean, optionHighlighted: boolean, isInputEmpty: boolean): {
450
+ key: string;
451
+ hint: string;
452
+ };
453
+
418
454
  declare class ModeController {
419
455
  private container;
420
456
  private mode;
@@ -429,4 +465,4 @@ declare class ModeController {
429
465
  private detachListener;
430
466
  }
431
467
 
432
- export { AIAutocomplete, type APIConfig, type APIKeyConfig, type AccessTokenConfig, type AccessTokenResult, type AppearanceMode, type AutocompleteRequest, type AutocompleteResponse, type AutocompleteResult, type CompletedParam, type CompletedParamState, type CoreOptions, type CoreState, type InputItem, ModeController, type OptionOverrides, type RenderMode, type Segment, type Store, type Suggestion, type SuggestionOption, type TaskKind, buildQuery, createStore, cursorIsAtEnd, extractPlainText, getCursorOffset, plainTextLength, previousGraphemeBoundary, renderEditableContent, setCursorOffset };
468
+ export { AIAutocomplete, type APIConfig, type APIKeyConfig, type AccessTokenConfig, type AccessTokenResult, type AppearanceMode, type AutocompleteRequest, type AutocompleteResponse, type AutocompleteResult, type CompletedParam, type CompletedParamState, type CoreOptions, type CoreState, type InputItem, ModeController, type OptionOverrides, type RenderMode, type Segment, type Store, type Suggestion, type SuggestionOption, type TaskKind, buildQuery, createStore, cursorIsAtEnd, extractPlainText, getCursorOffset, getFooterHint, plainTextLength, previousGraphemeBoundary, renderEditableContent, setCursorOffset };
package/dist/index.d.ts CHANGED
@@ -136,6 +136,12 @@ interface CoreInputState {
136
136
  * Set by selectOption / ReEditManager.selectOption, cleared by a timer.
137
137
  */
138
138
  inSelectionAnimation: boolean;
139
+ /**
140
+ * True once the user has pressed Tab to highlight a dropdown option. Drives
141
+ * the dropdown footer hint: "tab to select" before the first Tab, then
142
+ * "→ to skip" afterwards. Sticky until `reset()` clears it.
143
+ */
144
+ hasTabbedToHighlight: boolean;
139
145
  }
140
146
  /**
141
147
  * Derived fields recomputed from {@link CoreInputState} + {@link CoreOptions}.
@@ -148,6 +154,18 @@ interface CoreDerivedState {
148
154
  filteredOptions: SuggestionOption[];
149
155
  placeholderText: string;
150
156
  isDropdownOpen: boolean;
157
+ /**
158
+ * Whether the active (leading) pill should render in its `selected` state
159
+ * (full opacity) rather than the de-emphasized `first` tier. True when the
160
+ * dropdown is open AND a tappable option is highlighted (`activeDropdownIndex
161
+ * >= 0 && is_tappable`). This rule is uniform across all trigger modes:
162
+ * - `auto`: becomes true on keyboard nav / hover / pill tap.
163
+ * - `manual`: becomes true on pill tap — `setActivePill` opens the dropdown
164
+ * and auto-highlights the first tappable option; false if the pill has no
165
+ * tappable option.
166
+ * - `hidden`: always false (the dropdown never opens).
167
+ */
168
+ isActivePillSelected: boolean;
151
169
  }
152
170
  /**
153
171
  * Full state shape (inputs + derived) exposed to consumers via `getState()`
@@ -415,6 +433,24 @@ interface BuildQueryResult {
415
433
  */
416
434
  declare function buildQuery(text: string, completedParams: CompletedParamState[]): BuildQueryResult;
417
435
 
436
+ /**
437
+ * The dropdown footer's keyboard hint has four states, in priority order:
438
+ * 1. an option is highlighted → "enter to proceed" (Enter commits it);
439
+ * 2. otherwise, the input is empty → "tab to skip" — with nothing typed there's
440
+ * nothing to select, so Tab skips the active pill. This holds regardless of
441
+ * whether the user has tabbed to highlight yet;
442
+ * 3. otherwise, the user has tabbed to highlight at some point → "→ to skip"
443
+ * (the right arrow skips the active pill);
444
+ * 4. otherwise (fresh, with text) → "tab to select".
445
+ *
446
+ * Pure computation — no DOM access. Shared by the vanilla renderer and the
447
+ * React / Angular footer components so the wording can't drift between them.
448
+ */
449
+ declare function getFooterHint(hasTabbedToHighlight: boolean, optionHighlighted: boolean, isInputEmpty: boolean): {
450
+ key: string;
451
+ hint: string;
452
+ };
453
+
418
454
  declare class ModeController {
419
455
  private container;
420
456
  private mode;
@@ -429,4 +465,4 @@ declare class ModeController {
429
465
  private detachListener;
430
466
  }
431
467
 
432
- export { AIAutocomplete, type APIConfig, type APIKeyConfig, type AccessTokenConfig, type AccessTokenResult, type AppearanceMode, type AutocompleteRequest, type AutocompleteResponse, type AutocompleteResult, type CompletedParam, type CompletedParamState, type CoreOptions, type CoreState, type InputItem, ModeController, type OptionOverrides, type RenderMode, type Segment, type Store, type Suggestion, type SuggestionOption, type TaskKind, buildQuery, createStore, cursorIsAtEnd, extractPlainText, getCursorOffset, plainTextLength, previousGraphemeBoundary, renderEditableContent, setCursorOffset };
468
+ export { AIAutocomplete, type APIConfig, type APIKeyConfig, type AccessTokenConfig, type AccessTokenResult, type AppearanceMode, type AutocompleteRequest, type AutocompleteResponse, type AutocompleteResult, type CompletedParam, type CompletedParamState, type CoreOptions, type CoreState, type InputItem, ModeController, type OptionOverrides, type RenderMode, type Segment, type Store, type Suggestion, type SuggestionOption, type TaskKind, buildQuery, createStore, cursorIsAtEnd, extractPlainText, getCursorOffset, getFooterHint, plainTextLength, previousGraphemeBoundary, renderEditableContent, setCursorOffset };