@magicx-eng/ai-autocomplete-vanilla 0.32.2 → 0.34.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 +9 -1
- package/dist/index.d.mts +85 -1
- package/dist/index.d.ts +85 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -647,7 +647,9 @@ unsub();
|
|
|
647
647
|
| `removeLastParam()` | Remove the last completed param from state. The text stays in the input as plain text. |
|
|
648
648
|
| `clearNewParamId()` | Clear shimmer animation state. |
|
|
649
649
|
| `reset()` | Clear all state, re-fetch initial suggestions, and start a new session (rotates `session_id`). Call this after handling submit. |
|
|
650
|
-
| `
|
|
650
|
+
| `recordSubmit(result)` | Record a submit from a button you render. Enter and the built-in button are recorded for you; call this once per submit from your own button. |
|
|
651
|
+
| `setValue(text)` | Set text (controlled mode). Text set this way is not reported as the user starting a search. |
|
|
652
|
+
| `prefillText(text)` | Fill the field with text the user did not type — e.g. a query carried over from the previous page — and handle it like typing: suggestions are fetched and the text is recognized. Not reported as the user starting a search. |
|
|
651
653
|
| `setCompletedParams(params)` | Set completed params (controlled mode). |
|
|
652
654
|
| `setMode(mode)` | Switch color mode at runtime. |
|
|
653
655
|
| `update(opts)` | Update multiple options at once (e.g. `animations`, `pillPlacement`, `dropdownTrigger`, `optionsPosition`). |
|
|
@@ -982,6 +984,12 @@ const ac = new AIAutocomplete(container, {
|
|
|
982
984
|
});
|
|
983
985
|
```
|
|
984
986
|
|
|
987
|
+
### Visitor id and submits
|
|
988
|
+
|
|
989
|
+
Pass `visitorId` to tie searches to what the same visitor does later: a UUID v4 you keep across page loads (for example a first-party cookie), or a function that returns one. A function is called only when the id is needed, so it is safe to create the id lazily inside it.
|
|
990
|
+
|
|
991
|
+
Submits from Enter and from the built-in submit button are recorded for you. If you render your own submit button (Tier 2 or 3), call `recordSubmit(result)` from it, once per submit, with the result you pass to your own submit handler.
|
|
992
|
+
|
|
985
993
|
## Option Overrides
|
|
986
994
|
|
|
987
995
|
Supply the options for a parameter yourself instead of taking the server's. Each entry is keyed by the suggestion `type` and is a function of the phrase the user has typed for that parameter:
|
package/dist/index.d.mts
CHANGED
|
@@ -109,6 +109,8 @@ interface AutocompleteResponse {
|
|
|
109
109
|
meta: {
|
|
110
110
|
request_id: string;
|
|
111
111
|
request_at: string;
|
|
112
|
+
/** The server's funnel-telemetry switch. Absent means off: send no funnel events. */
|
|
113
|
+
funnel_telemetry?: boolean;
|
|
112
114
|
};
|
|
113
115
|
}
|
|
114
116
|
/** Comparison an {@link ExpressedFilter} applies to its value. */
|
|
@@ -880,6 +882,16 @@ interface CoreOptions {
|
|
|
880
882
|
* parameters and options to them.
|
|
881
883
|
*/
|
|
882
884
|
additionalContext?: Record<string, unknown>;
|
|
885
|
+
/**
|
|
886
|
+
* Stable id for this visitor, kept by the host across page loads (e.g. a
|
|
887
|
+
* first-party cookie). Rides on funnel telemetry so searches can be joined
|
|
888
|
+
* to what the visitor does afterwards. Must be a UUID v4; omit to send none.
|
|
889
|
+
*
|
|
890
|
+
* A function is called only once the server has switched funnel telemetry
|
|
891
|
+
* on, so a host that creates the id lazily (sets a cookie) creates nothing
|
|
892
|
+
* while it is off.
|
|
893
|
+
*/
|
|
894
|
+
visitorId?: string | (() => string | undefined);
|
|
883
895
|
columns?: number;
|
|
884
896
|
/** Where pills render in "full" mode. Default: "dropdown". Ignored in "dropdown" mode (always in dropdown). */
|
|
885
897
|
pillPlacement?: "inline" | "dropdown" | "hidden";
|
|
@@ -1064,6 +1076,19 @@ declare class AIAutocomplete {
|
|
|
1064
1076
|
private subscriberCount;
|
|
1065
1077
|
private emitter;
|
|
1066
1078
|
private sessionId;
|
|
1079
|
+
/** The /suggest request whose response is on screen; telemetry echoes it. */
|
|
1080
|
+
private lastRequestId;
|
|
1081
|
+
/** Session that already sent `search_started`, so it fires once per session. */
|
|
1082
|
+
private searchStartedSessionId;
|
|
1083
|
+
/**
|
|
1084
|
+
* The server's funnel-telemetry switch, from the latest response's meta.
|
|
1085
|
+
* `null` until a response says; no funnel event goes out before that.
|
|
1086
|
+
*/
|
|
1087
|
+
private funnelTelemetry;
|
|
1088
|
+
/** A `search_started` that happened before any response said whether to send it. */
|
|
1089
|
+
private pendingSearchStarted;
|
|
1090
|
+
/** What the last `impression` showed, so an identical response doesn't resend it. */
|
|
1091
|
+
private lastImpressionKey;
|
|
1067
1092
|
private readonly emitSubmit;
|
|
1068
1093
|
private readonly emitError;
|
|
1069
1094
|
constructor(container: HTMLElement, opts?: CoreOptions);
|
|
@@ -1074,6 +1099,21 @@ declare class AIAutocomplete {
|
|
|
1074
1099
|
private resetAfterSubmit;
|
|
1075
1100
|
destroy(): void;
|
|
1076
1101
|
setMode(mode: AppearanceMode): void;
|
|
1102
|
+
/**
|
|
1103
|
+
* Fill the field with text the shopper did not type — a query carried over
|
|
1104
|
+
* from the previous page, say — and handle it as if typed: suggestions are
|
|
1105
|
+
* fetched and the text is re-identified. Unlike typing, it does not count as
|
|
1106
|
+
* the shopper starting a search.
|
|
1107
|
+
*/
|
|
1108
|
+
prefillText(text: string): void;
|
|
1109
|
+
/**
|
|
1110
|
+
* Reports `search_started` once per session, when the shopper (not the
|
|
1111
|
+
* consumer) first puts something in an empty field: typing, or picking an
|
|
1112
|
+
* option. Decided at the call, not in a store subscriber: a consumer write
|
|
1113
|
+
* made from inside a listener is delivered after its call returns, so a
|
|
1114
|
+
* subscriber cannot tell whose write it is.
|
|
1115
|
+
*/
|
|
1116
|
+
private noteSearchStarted;
|
|
1077
1117
|
setValue(text: string): void;
|
|
1078
1118
|
setCompletedParams(params: CompletedParamState[]): void;
|
|
1079
1119
|
setActivePill(index: number): void;
|
|
@@ -1174,6 +1214,12 @@ declare class AIAutocomplete {
|
|
|
1174
1214
|
* highlight the keyboard has since moved elsewhere is left alone.
|
|
1175
1215
|
*/
|
|
1176
1216
|
clearHighlight(index: number): void;
|
|
1217
|
+
/**
|
|
1218
|
+
* Records a submit in telemetry. The SDK does this itself when it runs the
|
|
1219
|
+
* submit (Enter, or Tier 1's button); call it only from a submit path you
|
|
1220
|
+
* own — a button you render — so each submit is counted once.
|
|
1221
|
+
*/
|
|
1222
|
+
recordSubmit(result: AutocompleteResult): void;
|
|
1177
1223
|
/**
|
|
1178
1224
|
* Announce a product selection. The rendered cards call this on activation;
|
|
1179
1225
|
* headless consumers rendering their own strip call it themselves.
|
|
@@ -1184,6 +1230,7 @@ declare class AIAutocomplete {
|
|
|
1184
1230
|
*/
|
|
1185
1231
|
selectProduct(product: Product): void;
|
|
1186
1232
|
handleTextChange(value: string): void;
|
|
1233
|
+
private applyTextChange;
|
|
1187
1234
|
/** Page the datepicker back one month. No-op unless a date pill is active. */
|
|
1188
1235
|
showPreviousMonth(): void;
|
|
1189
1236
|
/** Page the datepicker forward one month. No-op unless a date pill is active. */
|
|
@@ -1251,8 +1298,15 @@ declare class AIAutocomplete {
|
|
|
1251
1298
|
on<E extends keyof AIAutocompleteEvents>(event: E, callback: (...args: AIAutocompleteEvents[E]) => void): () => void;
|
|
1252
1299
|
update(opts: CoreUpdateOptions): void;
|
|
1253
1300
|
selectOption(option: SuggestionOption): void;
|
|
1301
|
+
private applyOption;
|
|
1254
1302
|
private startSelectionAnimationTimer;
|
|
1303
|
+
private resolveVisitorId;
|
|
1255
1304
|
private resolveSource;
|
|
1305
|
+
/**
|
|
1306
|
+
* Records what a response put on screen: pills and their options in display
|
|
1307
|
+
* order, and the product cards. Positions are 1-based array order.
|
|
1308
|
+
*/
|
|
1309
|
+
private fireImpression;
|
|
1256
1310
|
private fireTelemetry;
|
|
1257
1311
|
private setupContainer;
|
|
1258
1312
|
private buildAndRenderFull;
|
|
@@ -1700,6 +1754,36 @@ declare function getCursorOffset(root: HTMLElement): number | null;
|
|
|
1700
1754
|
* get the browser's own scroll-to-caret behaviour.
|
|
1701
1755
|
*/
|
|
1702
1756
|
declare function setCursorOffset(root: HTMLElement, offset: number): void;
|
|
1757
|
+
/**
|
|
1758
|
+
* The chip a tap or click landed on, or null.
|
|
1759
|
+
*
|
|
1760
|
+
* Re-edit otherwise starts only from `selectionchange`, i.e. from wherever
|
|
1761
|
+
* the browser put the caret — which on touch devices is frequently not the
|
|
1762
|
+
* chip the finger was on. iOS Safari snaps a tap's caret to a word boundary
|
|
1763
|
+
* and, on the tap that focuses the field, commonly parks it at the end of the
|
|
1764
|
+
* text: inside the last chip when the input ends with one. The event target
|
|
1765
|
+
* is the element actually hit, so a tap anywhere on the chip, edges and
|
|
1766
|
+
* padding included, selects it.
|
|
1767
|
+
*
|
|
1768
|
+
* Both chip kinds report, matching the selectionchange path: the core decides
|
|
1769
|
+
* what a tap means (a completed param re-opens its options, an identified date
|
|
1770
|
+
* opens the calendar, anything else is inert).
|
|
1771
|
+
*
|
|
1772
|
+
* Returns null when the gesture left a range selection (a drag-select that
|
|
1773
|
+
* ends on a chip is a selection, not a tap).
|
|
1774
|
+
*/
|
|
1775
|
+
declare function chipIdFromTap(root: HTMLElement, target: EventTarget | null): string | null;
|
|
1776
|
+
/**
|
|
1777
|
+
* After a tap on a chip, make sure the caret is on that chip.
|
|
1778
|
+
*
|
|
1779
|
+
* The browser may have put the tap's caret somewhere else entirely (see
|
|
1780
|
+
* `chipIdFromTap`). Left there, the next `selectionchange` reads it as the
|
|
1781
|
+
* caret leaving the chip — or entering a different one — and closes or
|
|
1782
|
+
* redirects what the tap just opened. A caret already within the chip's
|
|
1783
|
+
* bounds (edges included) is left alone; otherwise it moves to the chip's
|
|
1784
|
+
* start, which every edit range includes.
|
|
1785
|
+
*/
|
|
1786
|
+
declare function keepCaretOnChip(root: HTMLElement, paramId: string): void;
|
|
1703
1787
|
/**
|
|
1704
1788
|
* True when the caret offset equals the editable's plain-text length —
|
|
1705
1789
|
* meaning the only content to the right is non-editable (e.g. trailing pills).
|
|
@@ -2215,4 +2299,4 @@ interface SubmitResultExtras {
|
|
|
2215
2299
|
*/
|
|
2216
2300
|
declare function buildSubmitResult(text: string, completedParams: CompletedParamState[], skippedParams?: SkippedParamState[], extras?: SubmitResultExtras): AutocompleteResult;
|
|
2217
2301
|
|
|
2218
|
-
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 CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, type DateMonthView, type DateRange, type DateSelection, type ExpressedFilter, type FilterOp, type FormatType, type IdentifiedParam, type IdentifiedParamState, type InputItem, type LooseDateOptions, type MatchedItem, type MatchedItems, ModeController, OPTIONS_GRID_MOBILE_QUERY, OPTION_ENTER_DELAY_VAR, OPTION_ENTER_FADE_MS, OPTION_ENTER_RISE_MS, OPTION_ENTER_RISE_PX, OPTION_ENTER_STAGGER_MS, type OptionOverride, type OptionOverrides, type OptionsGridLayout, type OptionsGridPlan, PLACEHOLDER_FADE_OUT_MS, PLACEHOLDER_LEAVING_ATTR, PLACEHOLDER_SWAP_GAP_MS, PLACEHOLDER_TYPE_MS, PLACEHOLDER_WORD_PAUSE_MS, PRODUCT_PATH_PREFIX, PRODUCT_ROW_PX_PER_LINE, type Product, type ProductImageFallback, type ProductRowMetrics, type ProductRowWheel, type ProductsConfig, type ProductsLayout, RANGE_SEPARATOR, type RecentlySuggested, type RenderMode, SCROLL_ARROW_ATTR, SCROLL_ARROW_BOTTOM_VAR, SCROLL_ARROW_CLASS, SCROLL_ARROW_FADE_MS, SCROLL_ARROW_LABEL, SCROLL_ARROW_SCROLL_IDLE_MS, SCROLL_ARROW_VISIBLE_ATTR, SKIPPED_PARAM_TEXT, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SkippedParamState, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type TaskKind, WEEKDAY_LABELS, addMonths, attachProductRowWheel, attachScrollArrow, buildAttributionUrl, buildDateOptions, buildQuery, buildSubmitResult, cellDay, cellIso, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateSelectionFor, extractPlainText, formatAbsoluteDate, formatDate, formatDateRange, formatOptionCount, getCursorOffset, getFooterHint, identifiedParamLabel, isCalendarFormat, isOptionsGridMobileViewport, isoDate, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, optionCountLabel, optionEnterDelayMs, optionHasImage, optionImageSrc, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, parseDate, parseLooseDate, parseLooseDateRange, plainTextLength, planOptionsGrid, previousGraphemeBoundary, productFromMatchedItem, productInitial, productRowWheelTarget, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, toWireIdentifiedParams, visibleDateRange, withSkippedParams };
|
|
2302
|
+
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 CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, type DateMonthView, type DateRange, type DateSelection, type ExpressedFilter, type FilterOp, type FormatType, type IdentifiedParam, type IdentifiedParamState, type InputItem, type LooseDateOptions, type MatchedItem, type MatchedItems, ModeController, OPTIONS_GRID_MOBILE_QUERY, OPTION_ENTER_DELAY_VAR, OPTION_ENTER_FADE_MS, OPTION_ENTER_RISE_MS, OPTION_ENTER_RISE_PX, OPTION_ENTER_STAGGER_MS, type OptionOverride, type OptionOverrides, type OptionsGridLayout, type OptionsGridPlan, PLACEHOLDER_FADE_OUT_MS, PLACEHOLDER_LEAVING_ATTR, PLACEHOLDER_SWAP_GAP_MS, PLACEHOLDER_TYPE_MS, PLACEHOLDER_WORD_PAUSE_MS, PRODUCT_PATH_PREFIX, PRODUCT_ROW_PX_PER_LINE, type Product, type ProductImageFallback, type ProductRowMetrics, type ProductRowWheel, type ProductsConfig, type ProductsLayout, RANGE_SEPARATOR, type RecentlySuggested, type RenderMode, SCROLL_ARROW_ATTR, SCROLL_ARROW_BOTTOM_VAR, SCROLL_ARROW_CLASS, SCROLL_ARROW_FADE_MS, SCROLL_ARROW_LABEL, SCROLL_ARROW_SCROLL_IDLE_MS, SCROLL_ARROW_VISIBLE_ATTR, SKIPPED_PARAM_TEXT, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SkippedParamState, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type TaskKind, WEEKDAY_LABELS, addMonths, attachProductRowWheel, attachScrollArrow, buildAttributionUrl, buildDateOptions, buildQuery, buildSubmitResult, cellDay, cellIso, chipIdFromTap, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateSelectionFor, extractPlainText, formatAbsoluteDate, formatDate, formatDateRange, formatOptionCount, getCursorOffset, getFooterHint, identifiedParamLabel, isCalendarFormat, isOptionsGridMobileViewport, isoDate, keepCaretOnChip, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, optionCountLabel, optionEnterDelayMs, optionHasImage, optionImageSrc, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, parseDate, parseLooseDate, parseLooseDateRange, plainTextLength, planOptionsGrid, previousGraphemeBoundary, productFromMatchedItem, productInitial, productRowWheelTarget, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, toWireIdentifiedParams, visibleDateRange, withSkippedParams };
|
package/dist/index.d.ts
CHANGED
|
@@ -109,6 +109,8 @@ interface AutocompleteResponse {
|
|
|
109
109
|
meta: {
|
|
110
110
|
request_id: string;
|
|
111
111
|
request_at: string;
|
|
112
|
+
/** The server's funnel-telemetry switch. Absent means off: send no funnel events. */
|
|
113
|
+
funnel_telemetry?: boolean;
|
|
112
114
|
};
|
|
113
115
|
}
|
|
114
116
|
/** Comparison an {@link ExpressedFilter} applies to its value. */
|
|
@@ -880,6 +882,16 @@ interface CoreOptions {
|
|
|
880
882
|
* parameters and options to them.
|
|
881
883
|
*/
|
|
882
884
|
additionalContext?: Record<string, unknown>;
|
|
885
|
+
/**
|
|
886
|
+
* Stable id for this visitor, kept by the host across page loads (e.g. a
|
|
887
|
+
* first-party cookie). Rides on funnel telemetry so searches can be joined
|
|
888
|
+
* to what the visitor does afterwards. Must be a UUID v4; omit to send none.
|
|
889
|
+
*
|
|
890
|
+
* A function is called only once the server has switched funnel telemetry
|
|
891
|
+
* on, so a host that creates the id lazily (sets a cookie) creates nothing
|
|
892
|
+
* while it is off.
|
|
893
|
+
*/
|
|
894
|
+
visitorId?: string | (() => string | undefined);
|
|
883
895
|
columns?: number;
|
|
884
896
|
/** Where pills render in "full" mode. Default: "dropdown". Ignored in "dropdown" mode (always in dropdown). */
|
|
885
897
|
pillPlacement?: "inline" | "dropdown" | "hidden";
|
|
@@ -1064,6 +1076,19 @@ declare class AIAutocomplete {
|
|
|
1064
1076
|
private subscriberCount;
|
|
1065
1077
|
private emitter;
|
|
1066
1078
|
private sessionId;
|
|
1079
|
+
/** The /suggest request whose response is on screen; telemetry echoes it. */
|
|
1080
|
+
private lastRequestId;
|
|
1081
|
+
/** Session that already sent `search_started`, so it fires once per session. */
|
|
1082
|
+
private searchStartedSessionId;
|
|
1083
|
+
/**
|
|
1084
|
+
* The server's funnel-telemetry switch, from the latest response's meta.
|
|
1085
|
+
* `null` until a response says; no funnel event goes out before that.
|
|
1086
|
+
*/
|
|
1087
|
+
private funnelTelemetry;
|
|
1088
|
+
/** A `search_started` that happened before any response said whether to send it. */
|
|
1089
|
+
private pendingSearchStarted;
|
|
1090
|
+
/** What the last `impression` showed, so an identical response doesn't resend it. */
|
|
1091
|
+
private lastImpressionKey;
|
|
1067
1092
|
private readonly emitSubmit;
|
|
1068
1093
|
private readonly emitError;
|
|
1069
1094
|
constructor(container: HTMLElement, opts?: CoreOptions);
|
|
@@ -1074,6 +1099,21 @@ declare class AIAutocomplete {
|
|
|
1074
1099
|
private resetAfterSubmit;
|
|
1075
1100
|
destroy(): void;
|
|
1076
1101
|
setMode(mode: AppearanceMode): void;
|
|
1102
|
+
/**
|
|
1103
|
+
* Fill the field with text the shopper did not type — a query carried over
|
|
1104
|
+
* from the previous page, say — and handle it as if typed: suggestions are
|
|
1105
|
+
* fetched and the text is re-identified. Unlike typing, it does not count as
|
|
1106
|
+
* the shopper starting a search.
|
|
1107
|
+
*/
|
|
1108
|
+
prefillText(text: string): void;
|
|
1109
|
+
/**
|
|
1110
|
+
* Reports `search_started` once per session, when the shopper (not the
|
|
1111
|
+
* consumer) first puts something in an empty field: typing, or picking an
|
|
1112
|
+
* option. Decided at the call, not in a store subscriber: a consumer write
|
|
1113
|
+
* made from inside a listener is delivered after its call returns, so a
|
|
1114
|
+
* subscriber cannot tell whose write it is.
|
|
1115
|
+
*/
|
|
1116
|
+
private noteSearchStarted;
|
|
1077
1117
|
setValue(text: string): void;
|
|
1078
1118
|
setCompletedParams(params: CompletedParamState[]): void;
|
|
1079
1119
|
setActivePill(index: number): void;
|
|
@@ -1174,6 +1214,12 @@ declare class AIAutocomplete {
|
|
|
1174
1214
|
* highlight the keyboard has since moved elsewhere is left alone.
|
|
1175
1215
|
*/
|
|
1176
1216
|
clearHighlight(index: number): void;
|
|
1217
|
+
/**
|
|
1218
|
+
* Records a submit in telemetry. The SDK does this itself when it runs the
|
|
1219
|
+
* submit (Enter, or Tier 1's button); call it only from a submit path you
|
|
1220
|
+
* own — a button you render — so each submit is counted once.
|
|
1221
|
+
*/
|
|
1222
|
+
recordSubmit(result: AutocompleteResult): void;
|
|
1177
1223
|
/**
|
|
1178
1224
|
* Announce a product selection. The rendered cards call this on activation;
|
|
1179
1225
|
* headless consumers rendering their own strip call it themselves.
|
|
@@ -1184,6 +1230,7 @@ declare class AIAutocomplete {
|
|
|
1184
1230
|
*/
|
|
1185
1231
|
selectProduct(product: Product): void;
|
|
1186
1232
|
handleTextChange(value: string): void;
|
|
1233
|
+
private applyTextChange;
|
|
1187
1234
|
/** Page the datepicker back one month. No-op unless a date pill is active. */
|
|
1188
1235
|
showPreviousMonth(): void;
|
|
1189
1236
|
/** Page the datepicker forward one month. No-op unless a date pill is active. */
|
|
@@ -1251,8 +1298,15 @@ declare class AIAutocomplete {
|
|
|
1251
1298
|
on<E extends keyof AIAutocompleteEvents>(event: E, callback: (...args: AIAutocompleteEvents[E]) => void): () => void;
|
|
1252
1299
|
update(opts: CoreUpdateOptions): void;
|
|
1253
1300
|
selectOption(option: SuggestionOption): void;
|
|
1301
|
+
private applyOption;
|
|
1254
1302
|
private startSelectionAnimationTimer;
|
|
1303
|
+
private resolveVisitorId;
|
|
1255
1304
|
private resolveSource;
|
|
1305
|
+
/**
|
|
1306
|
+
* Records what a response put on screen: pills and their options in display
|
|
1307
|
+
* order, and the product cards. Positions are 1-based array order.
|
|
1308
|
+
*/
|
|
1309
|
+
private fireImpression;
|
|
1256
1310
|
private fireTelemetry;
|
|
1257
1311
|
private setupContainer;
|
|
1258
1312
|
private buildAndRenderFull;
|
|
@@ -1700,6 +1754,36 @@ declare function getCursorOffset(root: HTMLElement): number | null;
|
|
|
1700
1754
|
* get the browser's own scroll-to-caret behaviour.
|
|
1701
1755
|
*/
|
|
1702
1756
|
declare function setCursorOffset(root: HTMLElement, offset: number): void;
|
|
1757
|
+
/**
|
|
1758
|
+
* The chip a tap or click landed on, or null.
|
|
1759
|
+
*
|
|
1760
|
+
* Re-edit otherwise starts only from `selectionchange`, i.e. from wherever
|
|
1761
|
+
* the browser put the caret — which on touch devices is frequently not the
|
|
1762
|
+
* chip the finger was on. iOS Safari snaps a tap's caret to a word boundary
|
|
1763
|
+
* and, on the tap that focuses the field, commonly parks it at the end of the
|
|
1764
|
+
* text: inside the last chip when the input ends with one. The event target
|
|
1765
|
+
* is the element actually hit, so a tap anywhere on the chip, edges and
|
|
1766
|
+
* padding included, selects it.
|
|
1767
|
+
*
|
|
1768
|
+
* Both chip kinds report, matching the selectionchange path: the core decides
|
|
1769
|
+
* what a tap means (a completed param re-opens its options, an identified date
|
|
1770
|
+
* opens the calendar, anything else is inert).
|
|
1771
|
+
*
|
|
1772
|
+
* Returns null when the gesture left a range selection (a drag-select that
|
|
1773
|
+
* ends on a chip is a selection, not a tap).
|
|
1774
|
+
*/
|
|
1775
|
+
declare function chipIdFromTap(root: HTMLElement, target: EventTarget | null): string | null;
|
|
1776
|
+
/**
|
|
1777
|
+
* After a tap on a chip, make sure the caret is on that chip.
|
|
1778
|
+
*
|
|
1779
|
+
* The browser may have put the tap's caret somewhere else entirely (see
|
|
1780
|
+
* `chipIdFromTap`). Left there, the next `selectionchange` reads it as the
|
|
1781
|
+
* caret leaving the chip — or entering a different one — and closes or
|
|
1782
|
+
* redirects what the tap just opened. A caret already within the chip's
|
|
1783
|
+
* bounds (edges included) is left alone; otherwise it moves to the chip's
|
|
1784
|
+
* start, which every edit range includes.
|
|
1785
|
+
*/
|
|
1786
|
+
declare function keepCaretOnChip(root: HTMLElement, paramId: string): void;
|
|
1703
1787
|
/**
|
|
1704
1788
|
* True when the caret offset equals the editable's plain-text length —
|
|
1705
1789
|
* meaning the only content to the right is non-editable (e.g. trailing pills).
|
|
@@ -2215,4 +2299,4 @@ interface SubmitResultExtras {
|
|
|
2215
2299
|
*/
|
|
2216
2300
|
declare function buildSubmitResult(text: string, completedParams: CompletedParamState[], skippedParams?: SkippedParamState[], extras?: SubmitResultExtras): AutocompleteResult;
|
|
2217
2301
|
|
|
2218
|
-
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 CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, type DateMonthView, type DateRange, type DateSelection, type ExpressedFilter, type FilterOp, type FormatType, type IdentifiedParam, type IdentifiedParamState, type InputItem, type LooseDateOptions, type MatchedItem, type MatchedItems, ModeController, OPTIONS_GRID_MOBILE_QUERY, OPTION_ENTER_DELAY_VAR, OPTION_ENTER_FADE_MS, OPTION_ENTER_RISE_MS, OPTION_ENTER_RISE_PX, OPTION_ENTER_STAGGER_MS, type OptionOverride, type OptionOverrides, type OptionsGridLayout, type OptionsGridPlan, PLACEHOLDER_FADE_OUT_MS, PLACEHOLDER_LEAVING_ATTR, PLACEHOLDER_SWAP_GAP_MS, PLACEHOLDER_TYPE_MS, PLACEHOLDER_WORD_PAUSE_MS, PRODUCT_PATH_PREFIX, PRODUCT_ROW_PX_PER_LINE, type Product, type ProductImageFallback, type ProductRowMetrics, type ProductRowWheel, type ProductsConfig, type ProductsLayout, RANGE_SEPARATOR, type RecentlySuggested, type RenderMode, SCROLL_ARROW_ATTR, SCROLL_ARROW_BOTTOM_VAR, SCROLL_ARROW_CLASS, SCROLL_ARROW_FADE_MS, SCROLL_ARROW_LABEL, SCROLL_ARROW_SCROLL_IDLE_MS, SCROLL_ARROW_VISIBLE_ATTR, SKIPPED_PARAM_TEXT, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SkippedParamState, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type TaskKind, WEEKDAY_LABELS, addMonths, attachProductRowWheel, attachScrollArrow, buildAttributionUrl, buildDateOptions, buildQuery, buildSubmitResult, cellDay, cellIso, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateSelectionFor, extractPlainText, formatAbsoluteDate, formatDate, formatDateRange, formatOptionCount, getCursorOffset, getFooterHint, identifiedParamLabel, isCalendarFormat, isOptionsGridMobileViewport, isoDate, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, optionCountLabel, optionEnterDelayMs, optionHasImage, optionImageSrc, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, parseDate, parseLooseDate, parseLooseDateRange, plainTextLength, planOptionsGrid, previousGraphemeBoundary, productFromMatchedItem, productInitial, productRowWheelTarget, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, toWireIdentifiedParams, visibleDateRange, withSkippedParams };
|
|
2302
|
+
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 CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, type DateMonthView, type DateRange, type DateSelection, type ExpressedFilter, type FilterOp, type FormatType, type IdentifiedParam, type IdentifiedParamState, type InputItem, type LooseDateOptions, type MatchedItem, type MatchedItems, ModeController, OPTIONS_GRID_MOBILE_QUERY, OPTION_ENTER_DELAY_VAR, OPTION_ENTER_FADE_MS, OPTION_ENTER_RISE_MS, OPTION_ENTER_RISE_PX, OPTION_ENTER_STAGGER_MS, type OptionOverride, type OptionOverrides, type OptionsGridLayout, type OptionsGridPlan, PLACEHOLDER_FADE_OUT_MS, PLACEHOLDER_LEAVING_ATTR, PLACEHOLDER_SWAP_GAP_MS, PLACEHOLDER_TYPE_MS, PLACEHOLDER_WORD_PAUSE_MS, PRODUCT_PATH_PREFIX, PRODUCT_ROW_PX_PER_LINE, type Product, type ProductImageFallback, type ProductRowMetrics, type ProductRowWheel, type ProductsConfig, type ProductsLayout, RANGE_SEPARATOR, type RecentlySuggested, type RenderMode, SCROLL_ARROW_ATTR, SCROLL_ARROW_BOTTOM_VAR, SCROLL_ARROW_CLASS, SCROLL_ARROW_FADE_MS, SCROLL_ARROW_LABEL, SCROLL_ARROW_SCROLL_IDLE_MS, SCROLL_ARROW_VISIBLE_ATTR, SKIPPED_PARAM_TEXT, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SkippedParamState, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type TaskKind, WEEKDAY_LABELS, addMonths, attachProductRowWheel, attachScrollArrow, buildAttributionUrl, buildDateOptions, buildQuery, buildSubmitResult, cellDay, cellIso, chipIdFromTap, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateSelectionFor, extractPlainText, formatAbsoluteDate, formatDate, formatDateRange, formatOptionCount, getCursorOffset, getFooterHint, identifiedParamLabel, isCalendarFormat, isOptionsGridMobileViewport, isoDate, keepCaretOnChip, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, optionCountLabel, optionEnterDelayMs, optionHasImage, optionImageSrc, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, parseDate, parseLooseDate, parseLooseDateRange, plainTextLength, planOptionsGrid, previousGraphemeBoundary, productFromMatchedItem, productInitial, productRowWheelTarget, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, toWireIdentifiedParams, visibleDateRange, withSkippedParams };
|