@magicx-eng/ai-autocomplete-vanilla 0.53.1 → 0.55.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 +34 -0
- package/dist/index.d.mts +45 -2
- package/dist/index.d.ts +45 -2
- package/dist/index.js +144 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +144 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -140,6 +140,7 @@ const ac = new AIAutocomplete(container, {
|
|
|
140
140
|
onFocus: () => { ... },
|
|
141
141
|
onBlur: () => { ... },
|
|
142
142
|
onProductSelect: (product) => { ... }, // see "Product strip"
|
|
143
|
+
onProductAddToCart: (product) => { ... }, // see "Add to cart"
|
|
143
144
|
|
|
144
145
|
// Controlled mode
|
|
145
146
|
value: "initial text",
|
|
@@ -166,6 +167,7 @@ ac.destroy(); // Remove DOM, listeners, timers
|
|
|
166
167
|
ac.setMode("dark"); // Switch color mode
|
|
167
168
|
ac.update({ animations: false, optionsPosition: "above" });
|
|
168
169
|
ac.selectProduct(product); // Emit onProductSelect (Tier 3 / custom strips)
|
|
170
|
+
ac.addProductToCart(product); // Call onProductAddToCart (Tier 3 / custom strips)
|
|
169
171
|
ac.prepareSubmit(); // Prepare the typed word before your own button builds a result
|
|
170
172
|
ac.getResult(); // The AutocompleteResult as it stands right now
|
|
171
173
|
ac.getRequestId(); // The latest applied /suggest request ID, or null
|
|
@@ -278,6 +280,36 @@ without additional SDK options.
|
|
|
278
280
|
}
|
|
279
281
|
```
|
|
280
282
|
|
|
283
|
+
#### Add to cart
|
|
284
|
+
|
|
285
|
+
Pass `onProductAddToCart` and every card that isn't sold out gets a round
|
|
286
|
+
add-to-cart button in the bottom right corner of its image. Sold-out cards
|
|
287
|
+
(`available: false`) get none. Pressing it calls your handler, not
|
|
288
|
+
`onProductSelect`. The card doesn't open, and the panel stays open. The SDK
|
|
289
|
+
never touches a cart; your handler does the adding:
|
|
290
|
+
|
|
291
|
+
```ts
|
|
292
|
+
new AIAutocomplete(container, {
|
|
293
|
+
apiConfig: { apiKey: "..." },
|
|
294
|
+
onProductAddToCart: async (product) => {
|
|
295
|
+
const res = await fetch("/cart/add", { method: "POST", body: JSON.stringify({ id: product.id }) });
|
|
296
|
+
if (!res.ok) throw new Error(`cart ${res.status}`);
|
|
297
|
+
},
|
|
298
|
+
});
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
Return a promise to have the button show progress. It carries
|
|
302
|
+
`data-aia-cart-state="adding"` while the promise is pending, then `"added"`
|
|
303
|
+
(the cart glyph turns into a check) once it resolves. The check stays until the
|
|
304
|
+
card's product changes (a price-only change keeps it); pressing it again adds
|
|
305
|
+
another unit, going back through `"adding"` to `"added"`. A rejection returns
|
|
306
|
+
it to rest. Style it with
|
|
307
|
+
`--aia-product-cart-size` (28px), `--aia-product-cart-bg` and
|
|
308
|
+
`--aia-product-cart-color`, or `[data-aia-product-cart]`. In the list layout
|
|
309
|
+
the button sits at the row's right end. Headless consumers rendering
|
|
310
|
+
their own cards call `addProductToCart(product)`, which resolves or rejects
|
|
311
|
+
with the handler.
|
|
312
|
+
|
|
281
313
|
#### The catalog report (`customFields`)
|
|
282
314
|
|
|
283
315
|
Every response that read the catalog also says what it did with the query, and
|
|
@@ -1059,6 +1091,8 @@ Submits from Enter and from the built-in submit button are recorded for you. If
|
|
|
1059
1091
|
|
|
1060
1092
|
## Option Overrides
|
|
1061
1093
|
|
|
1094
|
+
Each suggestion request sends the current `optionOverrides` keys in `data.client_option_parameters` (or `[]` when absent), so the server skips client-supplied parameters that are not listed.
|
|
1095
|
+
|
|
1062
1096
|
Supply the options for a parameter yourself instead of taking the server's. Each entry is keyed by the suggestion `parameter` and is a function of the phrase the user has typed for that parameter:
|
|
1063
1097
|
|
|
1064
1098
|
```ts
|
package/dist/index.d.mts
CHANGED
|
@@ -88,6 +88,8 @@ interface Suggestion {
|
|
|
88
88
|
required: boolean;
|
|
89
89
|
options?: SuggestionOption[];
|
|
90
90
|
type?: SuggestionType;
|
|
91
|
+
/** The server sets this on LLM-written suggestions: true when options complete the typed word, false when they follow the typed text. */
|
|
92
|
+
completes_word?: boolean;
|
|
91
93
|
/**
|
|
92
94
|
* Asks for the Smart Suggestion look (sparkle and shimmer) on an ordinary
|
|
93
95
|
* question, such as one the server curated for a question query. It changes
|
|
@@ -145,6 +147,11 @@ interface AutocompleteRequest {
|
|
|
145
147
|
recently_suggested?: RecentlySuggested[];
|
|
146
148
|
contact_account_count?: number;
|
|
147
149
|
additional_context?: Record<string, unknown>;
|
|
150
|
+
/**
|
|
151
|
+
* Parameters whose options the consumer supplies through `optionOverrides`.
|
|
152
|
+
* The server skips a client-supplied parameter that is not listed.
|
|
153
|
+
*/
|
|
154
|
+
client_option_parameters: string[];
|
|
148
155
|
/** Tells the server this client can show option-value completions of the word being typed. */
|
|
149
156
|
accepts_traditional_autocomplete?: boolean;
|
|
150
157
|
};
|
|
@@ -1181,6 +1188,20 @@ interface CoreOptions {
|
|
|
1181
1188
|
* cmd-click and "copy link address" keep working, and don't fire this.
|
|
1182
1189
|
*/
|
|
1183
1190
|
onProductSelect?: (product: Product) => void;
|
|
1191
|
+
/**
|
|
1192
|
+
* Adds a product to the cart from its card. When set, every card that isn't
|
|
1193
|
+
* sold out (`available: false`) shows an add-to-cart button in the bottom
|
|
1194
|
+
* right corner of its image. When unset, no card has one. Pressing the button
|
|
1195
|
+
* calls this, not `onProductSelect`, and the panel stays open. The SDK never
|
|
1196
|
+
* touches a cart itself; the integration does the adding.
|
|
1197
|
+
*
|
|
1198
|
+
* Return a promise to have the button show progress. It carries
|
|
1199
|
+
* `data-aia-cart-state="adding"` until the promise settles, then `"added"` if
|
|
1200
|
+
* it resolved. `"added"` stays until the card's product changes; pressing
|
|
1201
|
+
* again adds another unit (adding → added again). A rejection puts the button
|
|
1202
|
+
* back at rest.
|
|
1203
|
+
*/
|
|
1204
|
+
onProductAddToCart?: (product: Product) => void | PromiseLike<unknown>;
|
|
1184
1205
|
value?: string;
|
|
1185
1206
|
completedParams?: CompletedParamState[];
|
|
1186
1207
|
/**
|
|
@@ -1204,7 +1225,7 @@ type AIAutocompleteEvents = {
|
|
|
1204
1225
|
blur: [];
|
|
1205
1226
|
productSelect: [product: Product];
|
|
1206
1227
|
};
|
|
1207
|
-
type CoreUpdateOptions = Partial<Omit<CoreOptions, "onSubmit" | "onResult" | "onError" | "onChange" | "onParamsChange" | "onStateChange" | "onFocus" | "onBlur" | "onProductSelect" | "styleRoot">>;
|
|
1228
|
+
type CoreUpdateOptions = Partial<Omit<CoreOptions, "onSubmit" | "onResult" | "onError" | "onChange" | "onParamsChange" | "onStateChange" | "onFocus" | "onBlur" | "onProductSelect" | "onProductAddToCart" | "styleRoot">>;
|
|
1208
1229
|
declare class AIAutocomplete {
|
|
1209
1230
|
private inputStore;
|
|
1210
1231
|
private store;
|
|
@@ -1396,6 +1417,15 @@ declare class AIAutocomplete {
|
|
|
1396
1417
|
* means "open the PDP", "add to cart" or "drop the title into the input".
|
|
1397
1418
|
*/
|
|
1398
1419
|
selectProduct(product: Product): void;
|
|
1420
|
+
/**
|
|
1421
|
+
* Add a product to the cart through `onProductAddToCart`. The rendered
|
|
1422
|
+
* cards' cart buttons call this; headless consumers rendering their own
|
|
1423
|
+
* strip call it themselves. Resolves once the handler's promise settles, and
|
|
1424
|
+
* rejects with its error. Without a handler it does nothing.
|
|
1425
|
+
*/
|
|
1426
|
+
addProductToCart(product: Product): Promise<void>;
|
|
1427
|
+
/** Whether cards draw a cart button: an `onProductAddToCart` handler is set. */
|
|
1428
|
+
hasProductAddToCart(): boolean;
|
|
1399
1429
|
handleTextChange(value: string): void;
|
|
1400
1430
|
private applyTextChange;
|
|
1401
1431
|
/** Page the datepicker back one month. No-op unless a date pill is active. */
|
|
@@ -2240,6 +2270,7 @@ declare const en: {
|
|
|
2240
2270
|
skipLabel: string;
|
|
2241
2271
|
products: string;
|
|
2242
2272
|
soldOut: string;
|
|
2273
|
+
addToCart: string;
|
|
2243
2274
|
submit: string;
|
|
2244
2275
|
scrollArrow: string;
|
|
2245
2276
|
keepTyping: string;
|
|
@@ -2368,6 +2399,18 @@ declare const PRODUCT_IMAGE_WIDTH = 360;
|
|
|
2368
2399
|
* stays relative.
|
|
2369
2400
|
*/
|
|
2370
2401
|
declare function shopifyImageSrc(url: string, width: number): string;
|
|
2402
|
+
/**
|
|
2403
|
+
* How much of a product card's square tile a photo fills, across and down:
|
|
2404
|
+
* the tile shows it whole (`object-fit: contain`), so a tall photo leaves a
|
|
2405
|
+
* margin either side and a wide one a margin above and below. The add-to-cart
|
|
2406
|
+
* button reads these (as `--aia-product-photo-fill-x` / `-y` on the card) to
|
|
2407
|
+
* sit inside the photo's own corner rather than the tile's. Null for a size
|
|
2408
|
+
* that isn't known yet.
|
|
2409
|
+
*/
|
|
2410
|
+
declare function productPhotoFill(naturalWidth: number, naturalHeight: number): {
|
|
2411
|
+
x: number;
|
|
2412
|
+
y: number;
|
|
2413
|
+
} | null;
|
|
2371
2414
|
/**
|
|
2372
2415
|
* The URLs a product card tries for `imageUrl`, in order (`imageSources` at
|
|
2373
2416
|
* the card width): trimmed, sized down when it is a Shopify-hosted PNG or WebP, with
|
|
@@ -2693,4 +2736,4 @@ declare const SMART_SUGGESTION_SPARKLE_SVG: string;
|
|
|
2693
2736
|
/** True when some pill is a question the shopper can decline. */
|
|
2694
2737
|
declare function hasSkippablePill(suggestions: Suggestion[]): boolean;
|
|
2695
2738
|
|
|
2696
|
-
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, 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, OPTION_IMAGE_WIDTH, 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_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 SkippedParamState, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type SuggestionType, type TaskKind, type TextPart, type UIStrings, VIEWPORT_FIT_ATTR, VIEWPORT_FIT_HEIGHT_VAR, type ViewportFitArgs, type ViewportFitController, WEEKDAY_LABELS, addMonths, attachProductRowWheel, attachScrollArrow, attachViewportFit, buildAttributionUrl, buildDateOptions, buildQuery, buildSubmitResult, cellDay, cellIso, chipIdFromTap, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateSelectionFor, extractPlainText, formatAbsoluteDate, formatDate, formatDateRange, formatOptionCount, getCursorOffset, getFooterHint, hasSkippablePill, highlightParts, identifiedParamLabel, isCalendarFormat, isOptionsGridMobileViewport, isSmartSuggestion, isTraditionalAutocompleteSuggestion, isoDate, keepCaretOnChip, labelTraditionalAutocomplete, matchTypedPhrase, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, optionCountLabel, optionEnterDelayMs, optionHasImage, optionImageSources, optionImageSrc, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, optionsShowLeadingVisuals, parseDate, parseLooseDate, parseLooseDateRange, plainTextLength, planOptionsGrid, previousGraphemeBoundary, productFromMatchedItem, productImageSources, productImageSrc, productInitial, productRowWheelTarget, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, shopifyImageSrc, toWireIdentifiedParams, typedFragment, uiStringsFor, visibleDateRange, withSkippedParams, withoutTraditionalAutocomplete };
|
|
2739
|
+
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, 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, OPTION_IMAGE_WIDTH, 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_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 SkippedParamState, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type SuggestionType, type TaskKind, type TextPart, type UIStrings, VIEWPORT_FIT_ATTR, VIEWPORT_FIT_HEIGHT_VAR, type ViewportFitArgs, type ViewportFitController, WEEKDAY_LABELS, addMonths, attachProductRowWheel, attachScrollArrow, attachViewportFit, buildAttributionUrl, buildDateOptions, buildQuery, buildSubmitResult, cellDay, cellIso, chipIdFromTap, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateSelectionFor, extractPlainText, formatAbsoluteDate, formatDate, formatDateRange, formatOptionCount, getCursorOffset, getFooterHint, hasSkippablePill, highlightParts, identifiedParamLabel, isCalendarFormat, isOptionsGridMobileViewport, isSmartSuggestion, isTraditionalAutocompleteSuggestion, isoDate, keepCaretOnChip, labelTraditionalAutocomplete, matchTypedPhrase, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, optionCountLabel, optionEnterDelayMs, optionHasImage, optionImageSources, optionImageSrc, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, optionsShowLeadingVisuals, parseDate, parseLooseDate, parseLooseDateRange, plainTextLength, planOptionsGrid, previousGraphemeBoundary, productFromMatchedItem, productImageSources, productImageSrc, productInitial, productPhotoFill, productRowWheelTarget, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, shopifyImageSrc, toWireIdentifiedParams, typedFragment, uiStringsFor, visibleDateRange, withSkippedParams, withoutTraditionalAutocomplete };
|
package/dist/index.d.ts
CHANGED
|
@@ -88,6 +88,8 @@ interface Suggestion {
|
|
|
88
88
|
required: boolean;
|
|
89
89
|
options?: SuggestionOption[];
|
|
90
90
|
type?: SuggestionType;
|
|
91
|
+
/** The server sets this on LLM-written suggestions: true when options complete the typed word, false when they follow the typed text. */
|
|
92
|
+
completes_word?: boolean;
|
|
91
93
|
/**
|
|
92
94
|
* Asks for the Smart Suggestion look (sparkle and shimmer) on an ordinary
|
|
93
95
|
* question, such as one the server curated for a question query. It changes
|
|
@@ -145,6 +147,11 @@ interface AutocompleteRequest {
|
|
|
145
147
|
recently_suggested?: RecentlySuggested[];
|
|
146
148
|
contact_account_count?: number;
|
|
147
149
|
additional_context?: Record<string, unknown>;
|
|
150
|
+
/**
|
|
151
|
+
* Parameters whose options the consumer supplies through `optionOverrides`.
|
|
152
|
+
* The server skips a client-supplied parameter that is not listed.
|
|
153
|
+
*/
|
|
154
|
+
client_option_parameters: string[];
|
|
148
155
|
/** Tells the server this client can show option-value completions of the word being typed. */
|
|
149
156
|
accepts_traditional_autocomplete?: boolean;
|
|
150
157
|
};
|
|
@@ -1181,6 +1188,20 @@ interface CoreOptions {
|
|
|
1181
1188
|
* cmd-click and "copy link address" keep working, and don't fire this.
|
|
1182
1189
|
*/
|
|
1183
1190
|
onProductSelect?: (product: Product) => void;
|
|
1191
|
+
/**
|
|
1192
|
+
* Adds a product to the cart from its card. When set, every card that isn't
|
|
1193
|
+
* sold out (`available: false`) shows an add-to-cart button in the bottom
|
|
1194
|
+
* right corner of its image. When unset, no card has one. Pressing the button
|
|
1195
|
+
* calls this, not `onProductSelect`, and the panel stays open. The SDK never
|
|
1196
|
+
* touches a cart itself; the integration does the adding.
|
|
1197
|
+
*
|
|
1198
|
+
* Return a promise to have the button show progress. It carries
|
|
1199
|
+
* `data-aia-cart-state="adding"` until the promise settles, then `"added"` if
|
|
1200
|
+
* it resolved. `"added"` stays until the card's product changes; pressing
|
|
1201
|
+
* again adds another unit (adding → added again). A rejection puts the button
|
|
1202
|
+
* back at rest.
|
|
1203
|
+
*/
|
|
1204
|
+
onProductAddToCart?: (product: Product) => void | PromiseLike<unknown>;
|
|
1184
1205
|
value?: string;
|
|
1185
1206
|
completedParams?: CompletedParamState[];
|
|
1186
1207
|
/**
|
|
@@ -1204,7 +1225,7 @@ type AIAutocompleteEvents = {
|
|
|
1204
1225
|
blur: [];
|
|
1205
1226
|
productSelect: [product: Product];
|
|
1206
1227
|
};
|
|
1207
|
-
type CoreUpdateOptions = Partial<Omit<CoreOptions, "onSubmit" | "onResult" | "onError" | "onChange" | "onParamsChange" | "onStateChange" | "onFocus" | "onBlur" | "onProductSelect" | "styleRoot">>;
|
|
1228
|
+
type CoreUpdateOptions = Partial<Omit<CoreOptions, "onSubmit" | "onResult" | "onError" | "onChange" | "onParamsChange" | "onStateChange" | "onFocus" | "onBlur" | "onProductSelect" | "onProductAddToCart" | "styleRoot">>;
|
|
1208
1229
|
declare class AIAutocomplete {
|
|
1209
1230
|
private inputStore;
|
|
1210
1231
|
private store;
|
|
@@ -1396,6 +1417,15 @@ declare class AIAutocomplete {
|
|
|
1396
1417
|
* means "open the PDP", "add to cart" or "drop the title into the input".
|
|
1397
1418
|
*/
|
|
1398
1419
|
selectProduct(product: Product): void;
|
|
1420
|
+
/**
|
|
1421
|
+
* Add a product to the cart through `onProductAddToCart`. The rendered
|
|
1422
|
+
* cards' cart buttons call this; headless consumers rendering their own
|
|
1423
|
+
* strip call it themselves. Resolves once the handler's promise settles, and
|
|
1424
|
+
* rejects with its error. Without a handler it does nothing.
|
|
1425
|
+
*/
|
|
1426
|
+
addProductToCart(product: Product): Promise<void>;
|
|
1427
|
+
/** Whether cards draw a cart button: an `onProductAddToCart` handler is set. */
|
|
1428
|
+
hasProductAddToCart(): boolean;
|
|
1399
1429
|
handleTextChange(value: string): void;
|
|
1400
1430
|
private applyTextChange;
|
|
1401
1431
|
/** Page the datepicker back one month. No-op unless a date pill is active. */
|
|
@@ -2240,6 +2270,7 @@ declare const en: {
|
|
|
2240
2270
|
skipLabel: string;
|
|
2241
2271
|
products: string;
|
|
2242
2272
|
soldOut: string;
|
|
2273
|
+
addToCart: string;
|
|
2243
2274
|
submit: string;
|
|
2244
2275
|
scrollArrow: string;
|
|
2245
2276
|
keepTyping: string;
|
|
@@ -2368,6 +2399,18 @@ declare const PRODUCT_IMAGE_WIDTH = 360;
|
|
|
2368
2399
|
* stays relative.
|
|
2369
2400
|
*/
|
|
2370
2401
|
declare function shopifyImageSrc(url: string, width: number): string;
|
|
2402
|
+
/**
|
|
2403
|
+
* How much of a product card's square tile a photo fills, across and down:
|
|
2404
|
+
* the tile shows it whole (`object-fit: contain`), so a tall photo leaves a
|
|
2405
|
+
* margin either side and a wide one a margin above and below. The add-to-cart
|
|
2406
|
+
* button reads these (as `--aia-product-photo-fill-x` / `-y` on the card) to
|
|
2407
|
+
* sit inside the photo's own corner rather than the tile's. Null for a size
|
|
2408
|
+
* that isn't known yet.
|
|
2409
|
+
*/
|
|
2410
|
+
declare function productPhotoFill(naturalWidth: number, naturalHeight: number): {
|
|
2411
|
+
x: number;
|
|
2412
|
+
y: number;
|
|
2413
|
+
} | null;
|
|
2371
2414
|
/**
|
|
2372
2415
|
* The URLs a product card tries for `imageUrl`, in order (`imageSources` at
|
|
2373
2416
|
* the card width): trimmed, sized down when it is a Shopify-hosted PNG or WebP, with
|
|
@@ -2693,4 +2736,4 @@ declare const SMART_SUGGESTION_SPARKLE_SVG: string;
|
|
|
2693
2736
|
/** True when some pill is a question the shopper can decline. */
|
|
2694
2737
|
declare function hasSkippablePill(suggestions: Suggestion[]): boolean;
|
|
2695
2738
|
|
|
2696
|
-
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, 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, OPTION_IMAGE_WIDTH, 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_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 SkippedParamState, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type SuggestionType, type TaskKind, type TextPart, type UIStrings, VIEWPORT_FIT_ATTR, VIEWPORT_FIT_HEIGHT_VAR, type ViewportFitArgs, type ViewportFitController, WEEKDAY_LABELS, addMonths, attachProductRowWheel, attachScrollArrow, attachViewportFit, buildAttributionUrl, buildDateOptions, buildQuery, buildSubmitResult, cellDay, cellIso, chipIdFromTap, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateSelectionFor, extractPlainText, formatAbsoluteDate, formatDate, formatDateRange, formatOptionCount, getCursorOffset, getFooterHint, hasSkippablePill, highlightParts, identifiedParamLabel, isCalendarFormat, isOptionsGridMobileViewport, isSmartSuggestion, isTraditionalAutocompleteSuggestion, isoDate, keepCaretOnChip, labelTraditionalAutocomplete, matchTypedPhrase, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, optionCountLabel, optionEnterDelayMs, optionHasImage, optionImageSources, optionImageSrc, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, optionsShowLeadingVisuals, parseDate, parseLooseDate, parseLooseDateRange, plainTextLength, planOptionsGrid, previousGraphemeBoundary, productFromMatchedItem, productImageSources, productImageSrc, productInitial, productRowWheelTarget, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, shopifyImageSrc, toWireIdentifiedParams, typedFragment, uiStringsFor, visibleDateRange, withSkippedParams, withoutTraditionalAutocomplete };
|
|
2739
|
+
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, 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, OPTION_IMAGE_WIDTH, 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_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 SkippedParamState, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type SuggestionType, type TaskKind, type TextPart, type UIStrings, VIEWPORT_FIT_ATTR, VIEWPORT_FIT_HEIGHT_VAR, type ViewportFitArgs, type ViewportFitController, WEEKDAY_LABELS, addMonths, attachProductRowWheel, attachScrollArrow, attachViewportFit, buildAttributionUrl, buildDateOptions, buildQuery, buildSubmitResult, cellDay, cellIso, chipIdFromTap, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateSelectionFor, extractPlainText, formatAbsoluteDate, formatDate, formatDateRange, formatOptionCount, getCursorOffset, getFooterHint, hasSkippablePill, highlightParts, identifiedParamLabel, isCalendarFormat, isOptionsGridMobileViewport, isSmartSuggestion, isTraditionalAutocompleteSuggestion, isoDate, keepCaretOnChip, labelTraditionalAutocomplete, matchTypedPhrase, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, optionCountLabel, optionEnterDelayMs, optionHasImage, optionImageSources, optionImageSrc, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, optionsShowLeadingVisuals, parseDate, parseLooseDate, parseLooseDateRange, plainTextLength, planOptionsGrid, previousGraphemeBoundary, productFromMatchedItem, productImageSources, productImageSrc, productInitial, productPhotoFill, productRowWheelTarget, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, shopifyImageSrc, toWireIdentifiedParams, typedFragment, uiStringsFor, visibleDateRange, withSkippedParams, withoutTraditionalAutocomplete };
|