@magicx-eng/ai-autocomplete-vanilla 0.78.0 → 0.79.1
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 +3 -3
- package/REFERENCE.md +17 -1
- package/dist/index.d.mts +46 -3
- package/dist/index.d.ts +46 -3
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @magicx-eng/ai-autocomplete-vanilla
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Intent-1 for any web page: an input and dropdown for search boxes and
|
|
4
4
|
other text inputs. As the user types, it suggests the next detail to add and
|
|
5
5
|
the options for it. It is plain TypeScript with no dependencies, so it works
|
|
6
6
|
with any stack: plain HTML, Vue, Svelte, React or Angular. React and Angular
|
|
@@ -30,10 +30,10 @@ Pass an empty container element, such as a `div`. The widget builds its own inpu
|
|
|
30
30
|
|
|
31
31
|
To get a key, create your product at https://ai-autocomplete.com/edit/logic (it sets what the box suggests), then create a public key at https://ai-autocomplete.com/account/keys. Public keys start with `pk_v1_` and are safe to ship in the browser.
|
|
32
32
|
|
|
33
|
-
- Docs: https://ai-
|
|
33
|
+
- Docs: https://magicx.ai/intent-1/docs/vanilla/getting-started
|
|
34
34
|
- Install with an AI coding agent: https://ai-autocomplete.com/install/vanilla.md
|
|
35
35
|
- Product strip and datepicker guides: [REFERENCE.md](https://unpkg.com/@magicx-eng/ai-autocomplete-vanilla/REFERENCE.md), also shipped in the package
|
|
36
|
-
- On Shopify?
|
|
36
|
+
- On Shopify? Install [AI Search, by Intent-1](https://apps.shopify.com/ai-autocomplete) to set this up without code.
|
|
37
37
|
|
|
38
38
|
## Features
|
|
39
39
|
|
package/REFERENCE.md
CHANGED
|
@@ -10,6 +10,7 @@ Longer guides that do not fit in the [README](https://unpkg.com/@magicx-eng/ai-a
|
|
|
10
10
|
- [Location search](#location-search)
|
|
11
11
|
- [CSS variables](#css-variables)
|
|
12
12
|
- [Visitor id kept by the SDK](#visitor-id-kept-by-the-sdk)
|
|
13
|
+
- [Search id](#search-id)
|
|
13
14
|
|
|
14
15
|
## Product strip
|
|
15
16
|
|
|
@@ -659,7 +660,7 @@ The full input also accepts `--aia-input-radius` and `--aia-written-text-font-we
|
|
|
659
660
|
| `--aia-dropdown-offset` | `13px` | `13px` | Gap between the input box and the dropdown (the dropdown's margin toward the input). |
|
|
660
661
|
| `--aia-content-inset-left` | `16px` | `16px` | Left inset of the SDK's content: the input wrapper's left padding, and the line the dropdown's content (parameter label, option text, product strip) starts on. Set it when you pad the field to clear a leading icon of your own, so the dropdown's content stays aligned under the typed text. Practical minimum is `10px` (the option text's own inset); both surfaces floor it there. |
|
|
661
662
|
| `--aia-footer-gap` | `12px` | `12px` | Breathing room above the dropdown footer (badge / keyboard hints), additive to the dropdown's 8px section gap. |
|
|
662
|
-
| `--aia-footer-chip-bg` | `--aia-surface` at 65% | `--aia-surface` at 65% | Fill behind the footer's keyboard hint and
|
|
663
|
+
| `--aia-footer-chip-bg` | `--aia-surface` at 65% | `--aia-surface` at 65% | Fill behind the footer's keyboard hint and "Powered by Intent-1" badge. The option list scrolls under the footer, so this keeps both legible over the row passing behind them. `transparent` on the glass surface. |
|
|
663
664
|
| `--aia-dropdown-bg` | — | — | Optional bg color the dropdown's "glass" rim shadow tints toward. Set this to the page background behind the dropdown so the bottom-corner glow blends seamlessly. |
|
|
664
665
|
| `--aia-scrollbar-track` | `rgba(15, 23, 42, 0.05)` | `rgba(255, 255, 255, 0.08)` | The floating options box's thin scrollbar track, shown while a long list overflows. |
|
|
665
666
|
| `--aia-scrollbar-thumb` | `rgba(15, 23, 42, 0.22)` | `rgba(255, 255, 255, 0.28)` | That scrollbar's thumb. |
|
|
@@ -745,3 +746,18 @@ window.addEventListener("CookiebotOnDecline", () => ac.refreshAnalyticsConsent()
|
|
|
745
746
|
```
|
|
746
747
|
|
|
747
748
|
`getVisitorId()` returns the id the instance's events carry, so you can send it with your own events. It is `undefined` before the first response and whenever there is no id.
|
|
749
|
+
|
|
750
|
+
## Search id
|
|
751
|
+
|
|
752
|
+
Each search gets its own id, so what happens after it (a results page, a cart, an order) can be tied to the exact search. The SDK makes it: a new one starts with the widget, on `reset()`, and with the shopper's next input after a submit or a product pick. It rides on the SDK's own requests and events once the feature is enabled for your account; until then `getSearchId()` returns `undefined`.
|
|
753
|
+
|
|
754
|
+
Read it where the search is handed off, before the shopper types again:
|
|
755
|
+
|
|
756
|
+
```ts
|
|
757
|
+
onSubmit: (result) => {
|
|
758
|
+
const searchId = ac.getSearchId();
|
|
759
|
+
// Carry it to your results page, and send it with the events that follow.
|
|
760
|
+
},
|
|
761
|
+
```
|
|
762
|
+
|
|
763
|
+
The id of the last search the current tab handed off (a submit or a product pick) is also kept in `sessionStorage` under `aia:last-search`, as `{ id, at }`, where `at` is when it was handed off, in milliseconds since the epoch.
|
package/dist/index.d.mts
CHANGED
|
@@ -269,6 +269,11 @@ interface AutocompleteResponse {
|
|
|
269
269
|
* `visitorId` and reports analytics consent. Absent means off.
|
|
270
270
|
*/
|
|
271
271
|
sdk_visitor_id?: boolean;
|
|
272
|
+
/**
|
|
273
|
+
* Set when the SDK should send a `search_id`: the search each request and
|
|
274
|
+
* event belongs to. Absent means off.
|
|
275
|
+
*/
|
|
276
|
+
search_ids?: boolean;
|
|
272
277
|
/** The request's `schema_version`, echoed back. */
|
|
273
278
|
schema_version?: string;
|
|
274
279
|
};
|
|
@@ -283,6 +288,12 @@ interface ExpressedFilter {
|
|
|
283
288
|
parameter: string;
|
|
284
289
|
value: string;
|
|
285
290
|
op: FilterOp;
|
|
291
|
+
/**
|
|
292
|
+
* Filters with the same group came from one typed word ("fleece" read as a
|
|
293
|
+
* material and as a category). One of them is enough. Absent on a filter
|
|
294
|
+
* that has no alternatives.
|
|
295
|
+
*/
|
|
296
|
+
or_group?: string;
|
|
286
297
|
}
|
|
287
298
|
/**
|
|
288
299
|
* One catalog item the query narrowed down to, in the shape needed to render
|
|
@@ -377,6 +388,11 @@ interface CustomFieldsReport {
|
|
|
377
388
|
*/
|
|
378
389
|
dropped_filters: ExpressedFilter[];
|
|
379
390
|
items: MatchedItems;
|
|
391
|
+
/**
|
|
392
|
+
* The text part of the search, the words besides `applied_filters`. Send it
|
|
393
|
+
* as the text query of a site's own results page. It can be empty.
|
|
394
|
+
*/
|
|
395
|
+
search_query?: string;
|
|
380
396
|
}
|
|
381
397
|
interface CompletedParamState extends CompletedParam {
|
|
382
398
|
/** Client-only identity for values committed together. */
|
|
@@ -1700,6 +1716,12 @@ type AIAutocompleteEvents = {
|
|
|
1700
1716
|
productSelect: [product: Product];
|
|
1701
1717
|
};
|
|
1702
1718
|
type CoreUpdateOptions = Partial<Omit<CoreOptions, "onSubmit" | "onResult" | "onError" | "onChange" | "onParamsChange" | "onStateChange" | "onFocus" | "onBlur" | "onProductSelect" | "onProductAddToCart" | "styleRoot">>;
|
|
1719
|
+
/**
|
|
1720
|
+
* Where the last search this tab handed off (a submit or a product pick) is
|
|
1721
|
+
* kept, for the storefront's own events (the Shopify Web Pixel reads it):
|
|
1722
|
+
* `{ id, at }`, `at` the handoff's time in epoch ms.
|
|
1723
|
+
*/
|
|
1724
|
+
declare const LAST_SEARCH_KEY = "aia:last-search";
|
|
1703
1725
|
declare class AIAutocomplete {
|
|
1704
1726
|
private inputStore;
|
|
1705
1727
|
private store;
|
|
@@ -1725,6 +1747,16 @@ declare class AIAutocomplete {
|
|
|
1725
1747
|
private subscriberCount;
|
|
1726
1748
|
private emitter;
|
|
1727
1749
|
private sessionId;
|
|
1750
|
+
/**
|
|
1751
|
+
* The search in progress. A new one starts with the instance, on reset(),
|
|
1752
|
+
* and with the shopper's next input after a submit or a product pick: what
|
|
1753
|
+
* they do after handing a search off is the next search.
|
|
1754
|
+
*/
|
|
1755
|
+
private searchId;
|
|
1756
|
+
/** A submit or product pick ended the search; the next input starts another. */
|
|
1757
|
+
private searchHandedOff;
|
|
1758
|
+
/** The server's `search_ids`: send the search with requests and events. */
|
|
1759
|
+
private searchIds;
|
|
1728
1760
|
/** The /suggest request whose response is on screen; telemetry echoes it. */
|
|
1729
1761
|
private lastRequestId;
|
|
1730
1762
|
/** Session that already sent `search_started`, so it fires once per session. */
|
|
@@ -1927,6 +1959,13 @@ declare class AIAutocomplete {
|
|
|
1927
1959
|
* own — a button you render — so each submit is counted once.
|
|
1928
1960
|
*/
|
|
1929
1961
|
recordSubmit(result: AutocompleteResult): void;
|
|
1962
|
+
/**
|
|
1963
|
+
* The search in progress, to send with your own events from it (a results
|
|
1964
|
+
* page, a cart). Undefined until the feature is enabled for your account
|
|
1965
|
+
* and the first response has said so. Read it in `onSubmit` or
|
|
1966
|
+
* `onProductSelect`: the shopper's next input starts another search.
|
|
1967
|
+
*/
|
|
1968
|
+
getSearchId(): string | undefined;
|
|
1930
1969
|
/**
|
|
1931
1970
|
* The visitor id this instance's events carry right now, to send with your
|
|
1932
1971
|
* own events. Undefined while there is none: before the first response, or
|
|
@@ -2144,6 +2183,10 @@ declare class AIAutocomplete {
|
|
|
2144
2183
|
private startSelectionAnimationTimer;
|
|
2145
2184
|
private resolveVisitorId;
|
|
2146
2185
|
private resolveOwnVisitorId;
|
|
2186
|
+
/** The shopper's input after a search was handed off starts the next one. */
|
|
2187
|
+
private continueSearch;
|
|
2188
|
+
/** Remembers the search this tab ran last, for the storefront's own events. */
|
|
2189
|
+
private rememberSearch;
|
|
2147
2190
|
private resolveSource;
|
|
2148
2191
|
/**
|
|
2149
2192
|
* With `visible_impression`, the dropdown opening is itself an impression of
|
|
@@ -3486,8 +3529,8 @@ declare const HANDOFF_NOT_HANDLED: unique symbol;
|
|
|
3486
3529
|
*/
|
|
3487
3530
|
declare const SCHEMA_VERSION = "1.0";
|
|
3488
3531
|
|
|
3489
|
-
/** Base URL for the
|
|
3490
|
-
declare const ATTRIBUTION_URL = "https://ai-
|
|
3532
|
+
/** Base URL for the Intent-1 attribution link in the dropdown footer. */
|
|
3533
|
+
declare const ATTRIBUTION_URL = "https://magicx.ai/intent-1";
|
|
3491
3534
|
/**
|
|
3492
3535
|
* Builds the attribution link URL, appending a `utm_source` query param derived
|
|
3493
3536
|
* from the current page's hostname. This lets analytics attribute the referral to
|
|
@@ -3739,4 +3782,4 @@ declare const SMART_SUGGESTION_SPARKLE_SVG: string;
|
|
|
3739
3782
|
/** True when some pill is a question the shopper can decline. */
|
|
3740
3783
|
declare function hasSkippablePill(suggestions: Suggestion[]): boolean;
|
|
3741
3784
|
|
|
3742
|
-
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 CurrencyOptions, type CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, type DateMonthView, type DateRange, type DateSelection, EDITOR_GROW_MS, type ExpressedFilter, type FilterOp, type FormatType, HANDOFF_NOT_HANDLED, HINT_ATTR, HINT_EL_ATTR, HINT_HOLD_MS, type IdentifiedParam, type IdentifiedParamState, type InputItem, LOCATION_META_KEY, LOCATION_MIN_QUERY, type LocationPlace, type LocationStatus, type LocationView, type LooseDateOptions, MULTI_DONE_FIT_VAR, MULTI_SELECT_TOGGLE_MIN_PX, MULTI_SELECT_TOGGLE_SLOP_PX, 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, OPTION_IMAGE_WIDTH, type OptionOverride, type OptionOverrides, type OptionsGridLayout, type OptionsGridPlan, PANEL_ENTER_DELAY_MS, PANEL_ENTER_MS, PANEL_GHOST_CLASS, PANEL_GLIDE_MS, PANEL_LEAVE_MS, PLACEHOLDER_FADE_OUT_MS, PLACEHOLDER_LEAVING_ATTR, PLACEHOLDER_SWAP_GAP_MS, PLACEHOLDER_TYPE_MS, PLACEHOLDER_WORD_PAUSE_MS, PRODUCT_IMAGE_WIDTH, PRODUCT_PATH_PREFIX, PRODUCT_ROW_PX_PER_LINE, type PhraseMatch, type Product, type ProductImageFallback, type ProductRowMetrics, type ProductRowWheel, type ProductsConfig, type ProductsLayout, RANGE_SEPARATOR, type RecentlySuggested, type RenderMode, SCHEMA_VERSION, 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, SMART_SUGGESTION_SPARKLE_SVG, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SelectOptionOptions, type SkippedParamState, type StartingHintOption, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type SuggestionType, TIME_META_KEY, TIME_STEP_MINUTES, TIME_WHEEL_COLUMNS, TIME_WHEEL_ROW_HEIGHT, type TaskKind, type TextPart, type TimeParts, type TimePeriod, type TimeView, type TimeWheelColumn, type TimeWheelRow, type UIStrings, VIEWPORT_FIT_ATTR, VIEWPORT_FIT_HEIGHT_VAR, type ViewportFitArgs, type ViewportFitController, WEEKDAY_LABELS, addMonths, attachChipRemove, attachProductRowWheel, attachScrollArrow, attachViewportFit, buildAttributionUrl, buildDateOptions, buildLocationOption, buildQuery, buildSubmitResult, buildTimeOption, cancelStartingHint, cellDay, cellIso, chipIdFromTap, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateFloorFor, dateSelectionFor, destroyPanelMorph, dropdownPillsFor, editingSuggestion, extractPlainText, findMultiSelectDone, fitMultiSelectDone, formatAbsoluteDate, formatDate, formatDateRange, formatOptionCount, formatPlace, formatTime, getCursorOffset, getFooterHint, hasSkippablePill, highlightParts, identifiedParamLabel, inPanelGhost, isCalendarFormat, isDimmedDay, isMultiSelectToggleTap, isOptionsGridMobileViewport, isPickerFormat, isSmartSuggestion, isTraditionalAutocompleteSuggestion, isoDate, isoTime, keepCaretOnChip, labelTraditionalAutocomplete, locationEndpointFor, matchTypedPhrase, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, notePanelMorphHeight, optionCountLabel, optionEnterDelayMs, optionHasImage, optionImageSources, optionImageSrc, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, optionsShowLeadingVisuals, panelMorphGlide, panelMorphKey, panelMorphTargetHeight, parseDate, parseLooseDate, parseLooseDateRange, parseTime, plainTextLength, planOptionsGrid, pointerMayHighlight, previousGraphemeBoundary, productFromMatchedItem, productImageSources, productImageSrc, productInitial, productPhotoFill, productRowWheelTarget, productsFromCustomFields, queryLive, releasePanelHug, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, settlePanelMorph, shopifyImageSrc, startingHintOptions, syncHighlightScroll, syncPanelHug, timeWheelIndex, timeWheelIndexFromScroll, timeWheelRows, toWireIdentifiedParams, typedFragment, uiStringsFor, visibleDateRange, watchEditorHeight, withSkippedParams, withTimeWheelIndex, withoutTraditionalAutocomplete };
|
|
3785
|
+
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 CurrencyOptions, type CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, type DateMonthView, type DateRange, type DateSelection, EDITOR_GROW_MS, type ExpressedFilter, type FilterOp, type FormatType, HANDOFF_NOT_HANDLED, HINT_ATTR, HINT_EL_ATTR, HINT_HOLD_MS, type IdentifiedParam, type IdentifiedParamState, type InputItem, LAST_SEARCH_KEY, LOCATION_META_KEY, LOCATION_MIN_QUERY, type LocationPlace, type LocationStatus, type LocationView, type LooseDateOptions, MULTI_DONE_FIT_VAR, MULTI_SELECT_TOGGLE_MIN_PX, MULTI_SELECT_TOGGLE_SLOP_PX, 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, OPTION_IMAGE_WIDTH, type OptionOverride, type OptionOverrides, type OptionsGridLayout, type OptionsGridPlan, PANEL_ENTER_DELAY_MS, PANEL_ENTER_MS, PANEL_GHOST_CLASS, PANEL_GLIDE_MS, PANEL_LEAVE_MS, PLACEHOLDER_FADE_OUT_MS, PLACEHOLDER_LEAVING_ATTR, PLACEHOLDER_SWAP_GAP_MS, PLACEHOLDER_TYPE_MS, PLACEHOLDER_WORD_PAUSE_MS, PRODUCT_IMAGE_WIDTH, PRODUCT_PATH_PREFIX, PRODUCT_ROW_PX_PER_LINE, type PhraseMatch, type Product, type ProductImageFallback, type ProductRowMetrics, type ProductRowWheel, type ProductsConfig, type ProductsLayout, RANGE_SEPARATOR, type RecentlySuggested, type RenderMode, SCHEMA_VERSION, 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, SMART_SUGGESTION_SPARKLE_SVG, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SelectOptionOptions, type SkippedParamState, type StartingHintOption, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type SuggestionType, TIME_META_KEY, TIME_STEP_MINUTES, TIME_WHEEL_COLUMNS, TIME_WHEEL_ROW_HEIGHT, type TaskKind, type TextPart, type TimeParts, type TimePeriod, type TimeView, type TimeWheelColumn, type TimeWheelRow, type UIStrings, VIEWPORT_FIT_ATTR, VIEWPORT_FIT_HEIGHT_VAR, type ViewportFitArgs, type ViewportFitController, WEEKDAY_LABELS, addMonths, attachChipRemove, attachProductRowWheel, attachScrollArrow, attachViewportFit, buildAttributionUrl, buildDateOptions, buildLocationOption, buildQuery, buildSubmitResult, buildTimeOption, cancelStartingHint, cellDay, cellIso, chipIdFromTap, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateFloorFor, dateSelectionFor, destroyPanelMorph, dropdownPillsFor, editingSuggestion, extractPlainText, findMultiSelectDone, fitMultiSelectDone, formatAbsoluteDate, formatDate, formatDateRange, formatOptionCount, formatPlace, formatTime, getCursorOffset, getFooterHint, hasSkippablePill, highlightParts, identifiedParamLabel, inPanelGhost, isCalendarFormat, isDimmedDay, isMultiSelectToggleTap, isOptionsGridMobileViewport, isPickerFormat, isSmartSuggestion, isTraditionalAutocompleteSuggestion, isoDate, isoTime, keepCaretOnChip, labelTraditionalAutocomplete, locationEndpointFor, matchTypedPhrase, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, notePanelMorphHeight, optionCountLabel, optionEnterDelayMs, optionHasImage, optionImageSources, optionImageSrc, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, optionsShowLeadingVisuals, panelMorphGlide, panelMorphKey, panelMorphTargetHeight, parseDate, parseLooseDate, parseLooseDateRange, parseTime, plainTextLength, planOptionsGrid, pointerMayHighlight, previousGraphemeBoundary, productFromMatchedItem, productImageSources, productImageSrc, productInitial, productPhotoFill, productRowWheelTarget, productsFromCustomFields, queryLive, releasePanelHug, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, settlePanelMorph, shopifyImageSrc, startingHintOptions, syncHighlightScroll, syncPanelHug, timeWheelIndex, timeWheelIndexFromScroll, timeWheelRows, toWireIdentifiedParams, typedFragment, uiStringsFor, visibleDateRange, watchEditorHeight, withSkippedParams, withTimeWheelIndex, withoutTraditionalAutocomplete };
|
package/dist/index.d.ts
CHANGED
|
@@ -269,6 +269,11 @@ interface AutocompleteResponse {
|
|
|
269
269
|
* `visitorId` and reports analytics consent. Absent means off.
|
|
270
270
|
*/
|
|
271
271
|
sdk_visitor_id?: boolean;
|
|
272
|
+
/**
|
|
273
|
+
* Set when the SDK should send a `search_id`: the search each request and
|
|
274
|
+
* event belongs to. Absent means off.
|
|
275
|
+
*/
|
|
276
|
+
search_ids?: boolean;
|
|
272
277
|
/** The request's `schema_version`, echoed back. */
|
|
273
278
|
schema_version?: string;
|
|
274
279
|
};
|
|
@@ -283,6 +288,12 @@ interface ExpressedFilter {
|
|
|
283
288
|
parameter: string;
|
|
284
289
|
value: string;
|
|
285
290
|
op: FilterOp;
|
|
291
|
+
/**
|
|
292
|
+
* Filters with the same group came from one typed word ("fleece" read as a
|
|
293
|
+
* material and as a category). One of them is enough. Absent on a filter
|
|
294
|
+
* that has no alternatives.
|
|
295
|
+
*/
|
|
296
|
+
or_group?: string;
|
|
286
297
|
}
|
|
287
298
|
/**
|
|
288
299
|
* One catalog item the query narrowed down to, in the shape needed to render
|
|
@@ -377,6 +388,11 @@ interface CustomFieldsReport {
|
|
|
377
388
|
*/
|
|
378
389
|
dropped_filters: ExpressedFilter[];
|
|
379
390
|
items: MatchedItems;
|
|
391
|
+
/**
|
|
392
|
+
* The text part of the search, the words besides `applied_filters`. Send it
|
|
393
|
+
* as the text query of a site's own results page. It can be empty.
|
|
394
|
+
*/
|
|
395
|
+
search_query?: string;
|
|
380
396
|
}
|
|
381
397
|
interface CompletedParamState extends CompletedParam {
|
|
382
398
|
/** Client-only identity for values committed together. */
|
|
@@ -1700,6 +1716,12 @@ type AIAutocompleteEvents = {
|
|
|
1700
1716
|
productSelect: [product: Product];
|
|
1701
1717
|
};
|
|
1702
1718
|
type CoreUpdateOptions = Partial<Omit<CoreOptions, "onSubmit" | "onResult" | "onError" | "onChange" | "onParamsChange" | "onStateChange" | "onFocus" | "onBlur" | "onProductSelect" | "onProductAddToCart" | "styleRoot">>;
|
|
1719
|
+
/**
|
|
1720
|
+
* Where the last search this tab handed off (a submit or a product pick) is
|
|
1721
|
+
* kept, for the storefront's own events (the Shopify Web Pixel reads it):
|
|
1722
|
+
* `{ id, at }`, `at` the handoff's time in epoch ms.
|
|
1723
|
+
*/
|
|
1724
|
+
declare const LAST_SEARCH_KEY = "aia:last-search";
|
|
1703
1725
|
declare class AIAutocomplete {
|
|
1704
1726
|
private inputStore;
|
|
1705
1727
|
private store;
|
|
@@ -1725,6 +1747,16 @@ declare class AIAutocomplete {
|
|
|
1725
1747
|
private subscriberCount;
|
|
1726
1748
|
private emitter;
|
|
1727
1749
|
private sessionId;
|
|
1750
|
+
/**
|
|
1751
|
+
* The search in progress. A new one starts with the instance, on reset(),
|
|
1752
|
+
* and with the shopper's next input after a submit or a product pick: what
|
|
1753
|
+
* they do after handing a search off is the next search.
|
|
1754
|
+
*/
|
|
1755
|
+
private searchId;
|
|
1756
|
+
/** A submit or product pick ended the search; the next input starts another. */
|
|
1757
|
+
private searchHandedOff;
|
|
1758
|
+
/** The server's `search_ids`: send the search with requests and events. */
|
|
1759
|
+
private searchIds;
|
|
1728
1760
|
/** The /suggest request whose response is on screen; telemetry echoes it. */
|
|
1729
1761
|
private lastRequestId;
|
|
1730
1762
|
/** Session that already sent `search_started`, so it fires once per session. */
|
|
@@ -1927,6 +1959,13 @@ declare class AIAutocomplete {
|
|
|
1927
1959
|
* own — a button you render — so each submit is counted once.
|
|
1928
1960
|
*/
|
|
1929
1961
|
recordSubmit(result: AutocompleteResult): void;
|
|
1962
|
+
/**
|
|
1963
|
+
* The search in progress, to send with your own events from it (a results
|
|
1964
|
+
* page, a cart). Undefined until the feature is enabled for your account
|
|
1965
|
+
* and the first response has said so. Read it in `onSubmit` or
|
|
1966
|
+
* `onProductSelect`: the shopper's next input starts another search.
|
|
1967
|
+
*/
|
|
1968
|
+
getSearchId(): string | undefined;
|
|
1930
1969
|
/**
|
|
1931
1970
|
* The visitor id this instance's events carry right now, to send with your
|
|
1932
1971
|
* own events. Undefined while there is none: before the first response, or
|
|
@@ -2144,6 +2183,10 @@ declare class AIAutocomplete {
|
|
|
2144
2183
|
private startSelectionAnimationTimer;
|
|
2145
2184
|
private resolveVisitorId;
|
|
2146
2185
|
private resolveOwnVisitorId;
|
|
2186
|
+
/** The shopper's input after a search was handed off starts the next one. */
|
|
2187
|
+
private continueSearch;
|
|
2188
|
+
/** Remembers the search this tab ran last, for the storefront's own events. */
|
|
2189
|
+
private rememberSearch;
|
|
2147
2190
|
private resolveSource;
|
|
2148
2191
|
/**
|
|
2149
2192
|
* With `visible_impression`, the dropdown opening is itself an impression of
|
|
@@ -3486,8 +3529,8 @@ declare const HANDOFF_NOT_HANDLED: unique symbol;
|
|
|
3486
3529
|
*/
|
|
3487
3530
|
declare const SCHEMA_VERSION = "1.0";
|
|
3488
3531
|
|
|
3489
|
-
/** Base URL for the
|
|
3490
|
-
declare const ATTRIBUTION_URL = "https://ai-
|
|
3532
|
+
/** Base URL for the Intent-1 attribution link in the dropdown footer. */
|
|
3533
|
+
declare const ATTRIBUTION_URL = "https://magicx.ai/intent-1";
|
|
3491
3534
|
/**
|
|
3492
3535
|
* Builds the attribution link URL, appending a `utm_source` query param derived
|
|
3493
3536
|
* from the current page's hostname. This lets analytics attribute the referral to
|
|
@@ -3739,4 +3782,4 @@ declare const SMART_SUGGESTION_SPARKLE_SVG: string;
|
|
|
3739
3782
|
/** True when some pill is a question the shopper can decline. */
|
|
3740
3783
|
declare function hasSkippablePill(suggestions: Suggestion[]): boolean;
|
|
3741
3784
|
|
|
3742
|
-
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 CurrencyOptions, type CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, type DateMonthView, type DateRange, type DateSelection, EDITOR_GROW_MS, type ExpressedFilter, type FilterOp, type FormatType, HANDOFF_NOT_HANDLED, HINT_ATTR, HINT_EL_ATTR, HINT_HOLD_MS, type IdentifiedParam, type IdentifiedParamState, type InputItem, LOCATION_META_KEY, LOCATION_MIN_QUERY, type LocationPlace, type LocationStatus, type LocationView, type LooseDateOptions, MULTI_DONE_FIT_VAR, MULTI_SELECT_TOGGLE_MIN_PX, MULTI_SELECT_TOGGLE_SLOP_PX, 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, OPTION_IMAGE_WIDTH, type OptionOverride, type OptionOverrides, type OptionsGridLayout, type OptionsGridPlan, PANEL_ENTER_DELAY_MS, PANEL_ENTER_MS, PANEL_GHOST_CLASS, PANEL_GLIDE_MS, PANEL_LEAVE_MS, PLACEHOLDER_FADE_OUT_MS, PLACEHOLDER_LEAVING_ATTR, PLACEHOLDER_SWAP_GAP_MS, PLACEHOLDER_TYPE_MS, PLACEHOLDER_WORD_PAUSE_MS, PRODUCT_IMAGE_WIDTH, PRODUCT_PATH_PREFIX, PRODUCT_ROW_PX_PER_LINE, type PhraseMatch, type Product, type ProductImageFallback, type ProductRowMetrics, type ProductRowWheel, type ProductsConfig, type ProductsLayout, RANGE_SEPARATOR, type RecentlySuggested, type RenderMode, SCHEMA_VERSION, 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, SMART_SUGGESTION_SPARKLE_SVG, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SelectOptionOptions, type SkippedParamState, type StartingHintOption, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type SuggestionType, TIME_META_KEY, TIME_STEP_MINUTES, TIME_WHEEL_COLUMNS, TIME_WHEEL_ROW_HEIGHT, type TaskKind, type TextPart, type TimeParts, type TimePeriod, type TimeView, type TimeWheelColumn, type TimeWheelRow, type UIStrings, VIEWPORT_FIT_ATTR, VIEWPORT_FIT_HEIGHT_VAR, type ViewportFitArgs, type ViewportFitController, WEEKDAY_LABELS, addMonths, attachChipRemove, attachProductRowWheel, attachScrollArrow, attachViewportFit, buildAttributionUrl, buildDateOptions, buildLocationOption, buildQuery, buildSubmitResult, buildTimeOption, cancelStartingHint, cellDay, cellIso, chipIdFromTap, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateFloorFor, dateSelectionFor, destroyPanelMorph, dropdownPillsFor, editingSuggestion, extractPlainText, findMultiSelectDone, fitMultiSelectDone, formatAbsoluteDate, formatDate, formatDateRange, formatOptionCount, formatPlace, formatTime, getCursorOffset, getFooterHint, hasSkippablePill, highlightParts, identifiedParamLabel, inPanelGhost, isCalendarFormat, isDimmedDay, isMultiSelectToggleTap, isOptionsGridMobileViewport, isPickerFormat, isSmartSuggestion, isTraditionalAutocompleteSuggestion, isoDate, isoTime, keepCaretOnChip, labelTraditionalAutocomplete, locationEndpointFor, matchTypedPhrase, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, notePanelMorphHeight, optionCountLabel, optionEnterDelayMs, optionHasImage, optionImageSources, optionImageSrc, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, optionsShowLeadingVisuals, panelMorphGlide, panelMorphKey, panelMorphTargetHeight, parseDate, parseLooseDate, parseLooseDateRange, parseTime, plainTextLength, planOptionsGrid, pointerMayHighlight, previousGraphemeBoundary, productFromMatchedItem, productImageSources, productImageSrc, productInitial, productPhotoFill, productRowWheelTarget, productsFromCustomFields, queryLive, releasePanelHug, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, settlePanelMorph, shopifyImageSrc, startingHintOptions, syncHighlightScroll, syncPanelHug, timeWheelIndex, timeWheelIndexFromScroll, timeWheelRows, toWireIdentifiedParams, typedFragment, uiStringsFor, visibleDateRange, watchEditorHeight, withSkippedParams, withTimeWheelIndex, withoutTraditionalAutocomplete };
|
|
3785
|
+
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 CurrencyOptions, type CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, type DateMonthView, type DateRange, type DateSelection, EDITOR_GROW_MS, type ExpressedFilter, type FilterOp, type FormatType, HANDOFF_NOT_HANDLED, HINT_ATTR, HINT_EL_ATTR, HINT_HOLD_MS, type IdentifiedParam, type IdentifiedParamState, type InputItem, LAST_SEARCH_KEY, LOCATION_META_KEY, LOCATION_MIN_QUERY, type LocationPlace, type LocationStatus, type LocationView, type LooseDateOptions, MULTI_DONE_FIT_VAR, MULTI_SELECT_TOGGLE_MIN_PX, MULTI_SELECT_TOGGLE_SLOP_PX, 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, OPTION_IMAGE_WIDTH, type OptionOverride, type OptionOverrides, type OptionsGridLayout, type OptionsGridPlan, PANEL_ENTER_DELAY_MS, PANEL_ENTER_MS, PANEL_GHOST_CLASS, PANEL_GLIDE_MS, PANEL_LEAVE_MS, PLACEHOLDER_FADE_OUT_MS, PLACEHOLDER_LEAVING_ATTR, PLACEHOLDER_SWAP_GAP_MS, PLACEHOLDER_TYPE_MS, PLACEHOLDER_WORD_PAUSE_MS, PRODUCT_IMAGE_WIDTH, PRODUCT_PATH_PREFIX, PRODUCT_ROW_PX_PER_LINE, type PhraseMatch, type Product, type ProductImageFallback, type ProductRowMetrics, type ProductRowWheel, type ProductsConfig, type ProductsLayout, RANGE_SEPARATOR, type RecentlySuggested, type RenderMode, SCHEMA_VERSION, 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, SMART_SUGGESTION_SPARKLE_SVG, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SelectOptionOptions, type SkippedParamState, type StartingHintOption, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type SuggestionType, TIME_META_KEY, TIME_STEP_MINUTES, TIME_WHEEL_COLUMNS, TIME_WHEEL_ROW_HEIGHT, type TaskKind, type TextPart, type TimeParts, type TimePeriod, type TimeView, type TimeWheelColumn, type TimeWheelRow, type UIStrings, VIEWPORT_FIT_ATTR, VIEWPORT_FIT_HEIGHT_VAR, type ViewportFitArgs, type ViewportFitController, WEEKDAY_LABELS, addMonths, attachChipRemove, attachProductRowWheel, attachScrollArrow, attachViewportFit, buildAttributionUrl, buildDateOptions, buildLocationOption, buildQuery, buildSubmitResult, buildTimeOption, cancelStartingHint, cellDay, cellIso, chipIdFromTap, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateFloorFor, dateSelectionFor, destroyPanelMorph, dropdownPillsFor, editingSuggestion, extractPlainText, findMultiSelectDone, fitMultiSelectDone, formatAbsoluteDate, formatDate, formatDateRange, formatOptionCount, formatPlace, formatTime, getCursorOffset, getFooterHint, hasSkippablePill, highlightParts, identifiedParamLabel, inPanelGhost, isCalendarFormat, isDimmedDay, isMultiSelectToggleTap, isOptionsGridMobileViewport, isPickerFormat, isSmartSuggestion, isTraditionalAutocompleteSuggestion, isoDate, isoTime, keepCaretOnChip, labelTraditionalAutocomplete, locationEndpointFor, matchTypedPhrase, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, notePanelMorphHeight, optionCountLabel, optionEnterDelayMs, optionHasImage, optionImageSources, optionImageSrc, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, optionsShowLeadingVisuals, panelMorphGlide, panelMorphKey, panelMorphTargetHeight, parseDate, parseLooseDate, parseLooseDateRange, parseTime, plainTextLength, planOptionsGrid, pointerMayHighlight, previousGraphemeBoundary, productFromMatchedItem, productImageSources, productImageSrc, productInitial, productPhotoFill, productRowWheelTarget, productsFromCustomFields, queryLive, releasePanelHug, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, settlePanelMorph, shopifyImageSrc, startingHintOptions, syncHighlightScroll, syncPanelHug, timeWheelIndex, timeWheelIndexFromScroll, timeWheelRows, toWireIdentifiedParams, typedFragment, uiStringsFor, visibleDateRange, watchEditorHeight, withSkippedParams, withTimeWheelIndex, withoutTraditionalAutocomplete };
|