@magicx-eng/ai-autocomplete-vanilla 0.28.2 → 0.30.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 +61 -7
- package/dist/index.d.mts +22 -1
- package/dist/index.d.ts +22 -1
- package/dist/index.js +48 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -109,6 +109,8 @@ const ac = new AIAutocomplete(container, {
|
|
|
109
109
|
// How the strip lays its cards out: a scrolling row, or "list" — the same
|
|
110
110
|
// cards stacked as full-width rows.
|
|
111
111
|
productsLayout: "row",
|
|
112
|
+
// Missing/blank URL or load error: "image" (default) or the title initial.
|
|
113
|
+
productImageFallback: "image",
|
|
112
114
|
// Custom source for the strip. Omit it and the server's items are shown.
|
|
113
115
|
products: {
|
|
114
116
|
fetch: (query, signal) => myPlatform.search(query, { signal }),
|
|
@@ -122,6 +124,10 @@ const ac = new AIAutocomplete(container, {
|
|
|
122
124
|
// - HTMLElement: replaces the default button. Click events bubble up and trigger submit.
|
|
123
125
|
submitButton: undefined,
|
|
124
126
|
|
|
127
|
+
// Clear the input and start a new session after onSubmit (Tier 1 only).
|
|
128
|
+
// false keeps the query in place — e.g. when onSubmit navigates away.
|
|
129
|
+
resetOnSubmit: true,
|
|
130
|
+
|
|
125
131
|
// Events
|
|
126
132
|
onSubmit: (result) => { ... },
|
|
127
133
|
onResult: (result) => { ... }, // after every successful round-trip — see "Reading the query as it's built"
|
|
@@ -138,6 +144,15 @@ const ac = new AIAutocomplete(container, {
|
|
|
138
144
|
});
|
|
139
145
|
```
|
|
140
146
|
|
|
147
|
+
Product display options apply to both `renderMode: "full"` and
|
|
148
|
+
`renderMode: "dropdown"`, at construction and through `update()`:
|
|
149
|
+
|
|
150
|
+
| Option | Type | Default | Description |
|
|
151
|
+
|---|---|---|---|
|
|
152
|
+
| `showProducts?` | `boolean` | `true` | Show product cards whenever there are products to display. |
|
|
153
|
+
| `productsLayout?` | `"row" \| "list"` | `"row"` | Lay out cards as a scrolling row or a vertical list. |
|
|
154
|
+
| `productImageFallback?` | `"image" \| "initial"` | `"image"` | Fallback for a missing or blank product image URL, or an image load error. `"image"` shows the placeholder pictogram; `"initial"` shows the title initial. A working image still takes priority. See [Product strip](#product-strip). |
|
|
155
|
+
|
|
141
156
|
### Methods
|
|
142
157
|
|
|
143
158
|
```ts
|
|
@@ -151,7 +166,7 @@ ac.selectProduct(product); // Emit onProductSelect (Tier 3 / custom strips)
|
|
|
151
166
|
ac.getResult(); // The AutocompleteResult as it stands right now
|
|
152
167
|
```
|
|
153
168
|
|
|
154
|
-
> **Tier 1 auto-resets** after both Enter key and built-in submit-button clicks — your `onSubmit` runs, then the SDK clears the input and starts a new session. You don't need to call `ac.reset()` yourself in Tier 1.
|
|
169
|
+
> **Tier 1 auto-resets** after both Enter key and built-in submit-button clicks — your `onSubmit` runs, then the SDK clears the input and starts a new session. You don't need to call `ac.reset()` yourself in Tier 1. Pass `resetOnSubmit: false` to keep the query in place instead — useful when `onSubmit` navigates to a results page, where a cleared field would flash empty until the next page paints — and call `ac.reset()` yourself when you want a fresh session.
|
|
155
170
|
|
|
156
171
|
> `autoFocus`, `focus()`, and `blur()` only operate on the contentEditable editor the library owns (Tier 1 / `renderMode: "full"`). In Tier 2/3, the consumer owns the input and calls `.focus()` / `.blur()` on their own element; the `onFocus` / `onBlur` callbacks still fire whenever `setFocused()` is called.
|
|
157
172
|
|
|
@@ -204,6 +219,44 @@ default); `--aia-product-list-media-size` (44px) sizes the thumbnail and
|
|
|
204
219
|
is the horizontal strip. `update({ productsLayout })` re-lays the strip out at
|
|
205
220
|
once.
|
|
206
221
|
|
|
222
|
+
**Product image fallback.** A product's image takes priority when its
|
|
223
|
+
`imageUrl` loads successfully. A missing or blank URL, or an image load error,
|
|
224
|
+
uses `productImageFallback`: `"image"` (the default) shows the existing
|
|
225
|
+
placeholder pictogram; `"initial"` shows the first character of the trimmed,
|
|
226
|
+
uppercased title. This is a Unicode grapheme (so a combined character or emoji
|
|
227
|
+
stays together), with a Unicode code point fallback in older browsers. An
|
|
228
|
+
empty or whitespace-only title shows `?`. The fallback works in both row and
|
|
229
|
+
list layouts. Initial tiles are decorative (`aria-hidden="true"`); the card's
|
|
230
|
+
visible title supplies its text.
|
|
231
|
+
|
|
232
|
+
Set the option at construction or change it through `update()`. Both
|
|
233
|
+
rendered tiers (`"full"` and `"dropdown"`) apply it to the visible cards:
|
|
234
|
+
|
|
235
|
+
```ts
|
|
236
|
+
const ac = new AIAutocomplete(container, {
|
|
237
|
+
apiConfig: { apiKey: "..." },
|
|
238
|
+
productImageFallback: "initial",
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
// Switch existing fallback tiles back to the placeholder pictogram.
|
|
242
|
+
ac.update({ productImageFallback: "image" });
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
Style the initial tile itself with `[data-aia-product-initial]`. For
|
|
246
|
+
example, wrap the widget in an element with `id="catalog-search"` and add this
|
|
247
|
+
rule to your stylesheet. The existing `--aia-product-media-bg` variable sets
|
|
248
|
+
the background; `color`, `font-size` and `border-radius` style the initial
|
|
249
|
+
without additional SDK options.
|
|
250
|
+
|
|
251
|
+
```css
|
|
252
|
+
#catalog-search [data-aia-product-initial] {
|
|
253
|
+
--aia-product-media-bg: #eef2ff;
|
|
254
|
+
color: #4338ca;
|
|
255
|
+
font-size: 22px;
|
|
256
|
+
border-radius: 12px;
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
|
|
207
260
|
#### The catalog report (`customFields`)
|
|
208
261
|
|
|
209
262
|
Every response that read the catalog also says what it did with the query, and
|
|
@@ -294,7 +347,7 @@ type Product = {
|
|
|
294
347
|
id: string;
|
|
295
348
|
title: string;
|
|
296
349
|
url?: string; // absent = a card with no link (still activatable)
|
|
297
|
-
imageUrl?: string | null; // null
|
|
350
|
+
imageUrl?: string | null; // null uses the configured productImageFallback
|
|
298
351
|
price?: string; // pre-formatted by you
|
|
299
352
|
vendor?: string;
|
|
300
353
|
};
|
|
@@ -489,7 +542,7 @@ input.addEventListener("blur", () => ac.setFocused(false));
|
|
|
489
542
|
|
|
490
543
|
Pills always render inside the dropdown in this mode. The library creates the dropdown DOM inside your container — you just provide the element and wire up your input's events.
|
|
491
544
|
|
|
492
|
-
The [product strip](#product-strip) works here too: it renders inside the dropdown the library owns, from the server's items by default, and `products` / `showProducts` / `onProductSelect` behave exactly as in Tier 1.
|
|
545
|
+
The [product strip](#product-strip) works here too: it renders inside the dropdown the library owns, from the server's items by default, and `products` / `showProducts` / `productImageFallback` / `onProductSelect` behave exactly as in Tier 1.
|
|
493
546
|
|
|
494
547
|
> Focus/blur wiring is required when `dropdownTrigger` is `"auto"` (the default) — the dropdown only opens while the input is focused. Without `setFocused()`, the dropdown will never open.
|
|
495
548
|
|
|
@@ -809,10 +862,10 @@ Override these on the container element. The variables are declared with `:where
|
|
|
809
862
|
| `--aia-product-gap` | `8px` | `8px` | Gap between product cards. |
|
|
810
863
|
| `--aia-product-bg` | `transparent` | `transparent` | Product card background. |
|
|
811
864
|
| `--aia-product-bg-active` | `--aia-option-bg` | `--aia-option-bg` | Product card background on hover. |
|
|
812
|
-
| `--aia-product-media-bg` | `--aia-skeleton-bg` | `--aia-skeleton-bg` | Fill behind
|
|
865
|
+
| `--aia-product-media-bg` | `--aia-skeleton-bg` | `--aia-skeleton-bg` | Fill behind product images and both fallback tiles (placeholder pictogram or title initial), used when an image URL is missing, blank or fails to load. |
|
|
813
866
|
| `--aia-scroll-arrow-color` | `--aia-option-color` | `--aia-option-color` | Chevron color of the arrow (`--aia-scroll-arrow-color-hover` on hover). |
|
|
814
867
|
| `--aia-placeholder-fade` | `120ms` | `120ms` | Fade-out of the outgoing placeholder phrase when the starting-state placeholder changes (the incoming one types itself in). |
|
|
815
|
-
| `--aia-product-placeholder-image` | storefront pictogram | storefront pictogram | The
|
|
868
|
+
| `--aia-product-placeholder-image` | storefront pictogram | storefront pictogram | The pictogram used by `productImageFallback: "image"` (the default) when an image URL is missing, blank or fails to load. Defaults to a two-tone storefront inlined as a data URI. Set any `url(...)` to swap it; it is centered and contained over `--aia-product-media-bg`. Does not affect `"initial"` tiles. |
|
|
816
869
|
| `--aia-product-title-color` | `--aia-option-color-selected` | `--aia-option-color-selected` | Product title text. Follows the option colors by default, so theming the panel moves suggestions and products together. |
|
|
817
870
|
| `--aia-product-price-color` | `--aia-option-color-selected` | `--aia-option-color-selected` | Product price text. |
|
|
818
871
|
| `--aia-product-vendor-color` | `--aia-option-color` | `--aia-option-color` | Product vendor line. |
|
|
@@ -877,7 +930,8 @@ For styling beyond the CSS variables, target these stable `data-aia-*` attribute
|
|
|
877
930
|
| `[data-aia-products]` | Product strip section (label + row) |
|
|
878
931
|
| `[data-aia-products-row]` | The horizontally scrolling row of cards |
|
|
879
932
|
| `[data-aia-product]` | Each product card |
|
|
880
|
-
| `[data-aia-product-placeholder]` | Media tile
|
|
933
|
+
| `[data-aia-product-placeholder]` | Media tile showing the placeholder pictogram (`productImageFallback: "image"`) after a missing/blank URL or load error. The existing hook is unchanged. |
|
|
934
|
+
| `[data-aia-product-initial]` | The media tile itself when it shows the title initial (`productImageFallback: "initial"`). Decorative (`aria-hidden="true"`); target it to style the background, color, font size and border radius. |
|
|
881
935
|
|
|
882
936
|
Completed params render as inline `<strong>` elements inside the editor. Override their weight with `[data-aia-input] strong { font-weight: 700; }` — a selector that names the editor wins without `!important`, while a bare `strong { … }` page rule is kept out by the isolation reset.
|
|
883
937
|
|
|
@@ -898,7 +952,7 @@ The vanilla core also exposes stable BEM class names (`magicx-aia-*`); both can
|
|
|
898
952
|
|
|
899
953
|
Every `/api/suggest` request carries a `meta.session_id` UUID. A session runs from instance construction (or the last `reset()`) until the next `reset()`. All requests in one session share the same `session_id`; calling `reset()` starts a new one.
|
|
900
954
|
|
|
901
|
-
- **Tier 1 (`renderMode: "full"`)** — the SDK auto-resets after both Enter key and built-in submit-button clicks. Your `onSubmit` runs first, then the SDK clears the input and starts a new session.
|
|
955
|
+
- **Tier 1 (`renderMode: "full"`)** — the SDK auto-resets after both Enter key and built-in submit-button clicks. Your `onSubmit` runs first, then the SDK clears the input and starts a new session. With `resetOnSubmit: false` it doesn't, and the session continues until you call `reset()`.
|
|
902
956
|
- **Tier 2/3 (`renderMode: "dropdown" | "headless"`)** — you own the input and submit flow, so you must call `ac.reset()` yourself from your `onSubmit` handler (or from your custom submit button after firing `onSubmit`).
|
|
903
957
|
|
|
904
958
|
> **Why it matters:** suggestions get sharper as a query develops. Each one
|
package/dist/index.d.mts
CHANGED
|
@@ -358,6 +358,8 @@ interface Product {
|
|
|
358
358
|
* (courses, listings, documents) rather than products on a shelf.
|
|
359
359
|
*/
|
|
360
360
|
type ProductsLayout = "row" | "list";
|
|
361
|
+
/** What a product tile shows when its image is missing or fails to load. */
|
|
362
|
+
type ProductImageFallback = "image" | "initial";
|
|
361
363
|
/**
|
|
362
364
|
* Custom product-search wiring for the strip. Absent (the default), the strip
|
|
363
365
|
* shows the items the `/suggest` response itself reports as matching the query
|
|
@@ -939,6 +941,14 @@ interface CoreOptions {
|
|
|
939
941
|
* arrow button. Clicks on the provided element bubble up and trigger submit.
|
|
940
942
|
*/
|
|
941
943
|
submitButton?: HTMLElement | null;
|
|
944
|
+
/**
|
|
945
|
+
* Tier 1 ("full") only. When true (default), the input is cleared and a new
|
|
946
|
+
* session starts after `onSubmit` runs — on Enter and on the submit button.
|
|
947
|
+
* Set to false to leave the query in place: when `onSubmit` navigates away,
|
|
948
|
+
* a cleared field flashes empty until the next page paints. Call `reset()`
|
|
949
|
+
* yourself when you want a fresh session. Tiers 2/3 never auto-reset.
|
|
950
|
+
*/
|
|
951
|
+
resetOnSubmit?: boolean;
|
|
942
952
|
/**
|
|
943
953
|
* When true (default), the dropdown renders a horizontal row of product
|
|
944
954
|
* cards below the options grid whenever it has products to show: by default
|
|
@@ -961,6 +971,12 @@ interface CoreOptions {
|
|
|
961
971
|
* the strip out at once.
|
|
962
972
|
*/
|
|
963
973
|
productsLayout?: ProductsLayout;
|
|
974
|
+
/**
|
|
975
|
+
* Fallback for a missing or failed product image. "image" (default) uses
|
|
976
|
+
* the placeholder image; "initial" uses the title's first character.
|
|
977
|
+
* Style initial tiles with `[data-aia-product-initial]` in CSS.
|
|
978
|
+
*/
|
|
979
|
+
productImageFallback?: ProductImageFallback;
|
|
964
980
|
/**
|
|
965
981
|
* Custom source for the product strip. Omit it and the strip shows the items
|
|
966
982
|
* the `/suggest` response itself reports (`custom_fields.items`), with no
|
|
@@ -1054,6 +1070,8 @@ declare class AIAutocomplete {
|
|
|
1054
1070
|
focus(): void;
|
|
1055
1071
|
blur(): void;
|
|
1056
1072
|
reset(): void;
|
|
1073
|
+
/** Tier 1's post-submit reset. Read at call time so `update()` can flip it. */
|
|
1074
|
+
private resetAfterSubmit;
|
|
1057
1075
|
destroy(): void;
|
|
1058
1076
|
setMode(mode: AppearanceMode): void;
|
|
1059
1077
|
setValue(text: string): void;
|
|
@@ -2116,6 +2134,9 @@ declare class ModeController {
|
|
|
2116
2134
|
*/
|
|
2117
2135
|
declare function identifiedParamLabel(type: string): string;
|
|
2118
2136
|
|
|
2137
|
+
/** Uppercase first character for a product tile; an empty title displays "?". */
|
|
2138
|
+
declare function productInitial(title: string): string;
|
|
2139
|
+
|
|
2119
2140
|
/**
|
|
2120
2141
|
* Sentinel `text` marking a `completed_params` entry the user skipped (→)
|
|
2121
2142
|
* rather than filled. Sent regardless of `maskCompletedText` — it's a fixed
|
|
@@ -2166,4 +2187,4 @@ interface SubmitResultExtras {
|
|
|
2166
2187
|
*/
|
|
2167
2188
|
declare function buildSubmitResult(text: string, completedParams: CompletedParamState[], skippedParams?: SkippedParamState[], extras?: SubmitResultExtras): AutocompleteResult;
|
|
2168
2189
|
|
|
2169
|
-
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 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, 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, productRowWheelTarget, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, toWireIdentifiedParams, visibleDateRange, withSkippedParams };
|
|
2190
|
+
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, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -358,6 +358,8 @@ interface Product {
|
|
|
358
358
|
* (courses, listings, documents) rather than products on a shelf.
|
|
359
359
|
*/
|
|
360
360
|
type ProductsLayout = "row" | "list";
|
|
361
|
+
/** What a product tile shows when its image is missing or fails to load. */
|
|
362
|
+
type ProductImageFallback = "image" | "initial";
|
|
361
363
|
/**
|
|
362
364
|
* Custom product-search wiring for the strip. Absent (the default), the strip
|
|
363
365
|
* shows the items the `/suggest` response itself reports as matching the query
|
|
@@ -939,6 +941,14 @@ interface CoreOptions {
|
|
|
939
941
|
* arrow button. Clicks on the provided element bubble up and trigger submit.
|
|
940
942
|
*/
|
|
941
943
|
submitButton?: HTMLElement | null;
|
|
944
|
+
/**
|
|
945
|
+
* Tier 1 ("full") only. When true (default), the input is cleared and a new
|
|
946
|
+
* session starts after `onSubmit` runs — on Enter and on the submit button.
|
|
947
|
+
* Set to false to leave the query in place: when `onSubmit` navigates away,
|
|
948
|
+
* a cleared field flashes empty until the next page paints. Call `reset()`
|
|
949
|
+
* yourself when you want a fresh session. Tiers 2/3 never auto-reset.
|
|
950
|
+
*/
|
|
951
|
+
resetOnSubmit?: boolean;
|
|
942
952
|
/**
|
|
943
953
|
* When true (default), the dropdown renders a horizontal row of product
|
|
944
954
|
* cards below the options grid whenever it has products to show: by default
|
|
@@ -961,6 +971,12 @@ interface CoreOptions {
|
|
|
961
971
|
* the strip out at once.
|
|
962
972
|
*/
|
|
963
973
|
productsLayout?: ProductsLayout;
|
|
974
|
+
/**
|
|
975
|
+
* Fallback for a missing or failed product image. "image" (default) uses
|
|
976
|
+
* the placeholder image; "initial" uses the title's first character.
|
|
977
|
+
* Style initial tiles with `[data-aia-product-initial]` in CSS.
|
|
978
|
+
*/
|
|
979
|
+
productImageFallback?: ProductImageFallback;
|
|
964
980
|
/**
|
|
965
981
|
* Custom source for the product strip. Omit it and the strip shows the items
|
|
966
982
|
* the `/suggest` response itself reports (`custom_fields.items`), with no
|
|
@@ -1054,6 +1070,8 @@ declare class AIAutocomplete {
|
|
|
1054
1070
|
focus(): void;
|
|
1055
1071
|
blur(): void;
|
|
1056
1072
|
reset(): void;
|
|
1073
|
+
/** Tier 1's post-submit reset. Read at call time so `update()` can flip it. */
|
|
1074
|
+
private resetAfterSubmit;
|
|
1057
1075
|
destroy(): void;
|
|
1058
1076
|
setMode(mode: AppearanceMode): void;
|
|
1059
1077
|
setValue(text: string): void;
|
|
@@ -2116,6 +2134,9 @@ declare class ModeController {
|
|
|
2116
2134
|
*/
|
|
2117
2135
|
declare function identifiedParamLabel(type: string): string;
|
|
2118
2136
|
|
|
2137
|
+
/** Uppercase first character for a product tile; an empty title displays "?". */
|
|
2138
|
+
declare function productInitial(title: string): string;
|
|
2139
|
+
|
|
2119
2140
|
/**
|
|
2120
2141
|
* Sentinel `text` marking a `completed_params` entry the user skipped (→)
|
|
2121
2142
|
* rather than filled. Sent regardless of `maskCompletedText` — it's a fixed
|
|
@@ -2166,4 +2187,4 @@ interface SubmitResultExtras {
|
|
|
2166
2187
|
*/
|
|
2167
2188
|
declare function buildSubmitResult(text: string, completedParams: CompletedParamState[], skippedParams?: SkippedParamState[], extras?: SubmitResultExtras): AutocompleteResult;
|
|
2168
2189
|
|
|
2169
|
-
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 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, 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, productRowWheelTarget, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, toWireIdentifiedParams, visibleDateRange, withSkippedParams };
|
|
2190
|
+
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, 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 };
|