@magicx-eng/ai-autocomplete-vanilla 0.33.0 → 0.35.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 +19 -3
- package/dist/index.d.mts +70 -4
- package/dist/index.d.ts +70 -4
- package/dist/index.js +58 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -202,7 +202,10 @@ Each server item becomes a `Product` with `id` (the item's stable id), `title`,
|
|
|
202
202
|
currency is yours to add), `vendor`, `imageUrl`, and a `url`: the item's own
|
|
203
203
|
`item_url` when the uploaded catalog named one (absolute or root-relative;
|
|
204
204
|
anything else is ignored), else a **relative** `/products/{handle}` — the right
|
|
205
|
-
link for a Shopify widget running on the storefront itself
|
|
205
|
+
link for a Shopify widget running on the storefront itself — opened on the
|
|
206
|
+
variant the query chose (`?variant=…`, e.g. the blue one for "blue shoes") when
|
|
207
|
+
there is one, whose price and image the card then shows. `available` is carried
|
|
208
|
+
over when the server reports it. An item with
|
|
206
209
|
neither gets no `url`: its card is still activatable and still emits
|
|
207
210
|
`onProductSelect`, it just has nothing for cmd-click to open. `productFromMatchedItem` / `productsFromCustomFields` are
|
|
208
211
|
exported for a hand-rolled strip that wants the same mapping.
|
|
@@ -229,6 +232,17 @@ empty or whitespace-only title shows `?`. The fallback works in both row and
|
|
|
229
232
|
list layouts. Initial tiles are decorative (`aria-hidden="true"`); the card's
|
|
230
233
|
visible title supplies its text.
|
|
231
234
|
|
|
235
|
+
**Sold out.** A product with `available: false` shows a "Sold out" badge over
|
|
236
|
+
the top-left of its image (in the list layout, a smaller banner across the
|
|
237
|
+
bottom of the thumbnail) and its image is desaturated; the card stays
|
|
238
|
+
selectable and keeps its link. Absent or `true` shows no
|
|
239
|
+
badge, so leave `available` out when you don't know. The badge is part of the
|
|
240
|
+
card's text, so screen readers announce it. Theme it with
|
|
241
|
+
`--aia-product-badge-bg`, `--aia-product-badge-color`,
|
|
242
|
+
`--aia-product-badge-font-size` and `--aia-product-badge-inset`, and the list
|
|
243
|
+
banner with `--aia-product-badge-list-bg`, `--aia-product-badge-list-color` and
|
|
244
|
+
`--aia-product-badge-list-font-size`.
|
|
245
|
+
|
|
232
246
|
Set the option at construction or change it through `update()`. Both
|
|
233
247
|
rendered tiers (`"full"` and `"dropdown"`) apply it to the visible cards:
|
|
234
248
|
|
|
@@ -340,7 +354,7 @@ new AIAutocomplete(container, {
|
|
|
340
354
|
});
|
|
341
355
|
```
|
|
342
356
|
|
|
343
|
-
`Product` is exactly
|
|
357
|
+
`Product` is exactly seven fields; only `id` and `title` are required:
|
|
344
358
|
|
|
345
359
|
```ts
|
|
346
360
|
type Product = {
|
|
@@ -350,6 +364,7 @@ type Product = {
|
|
|
350
364
|
imageUrl?: string | null; // null uses the configured productImageFallback
|
|
351
365
|
price?: string; // pre-formatted by you
|
|
352
366
|
vendor?: string;
|
|
367
|
+
available?: boolean; // false shows a "Sold out" badge
|
|
353
368
|
};
|
|
354
369
|
```
|
|
355
370
|
|
|
@@ -648,7 +663,8 @@ unsub();
|
|
|
648
663
|
| `clearNewParamId()` | Clear shimmer animation state. |
|
|
649
664
|
| `reset()` | Clear all state, re-fetch initial suggestions, and start a new session (rotates `session_id`). Call this after handling submit. |
|
|
650
665
|
| `recordSubmit(result)` | Record a submit from a button you render. Enter and the built-in button are recorded for you; call this once per submit from your own button. |
|
|
651
|
-
| `setValue(text)` | Set text (controlled mode). |
|
|
666
|
+
| `setValue(text)` | Set text (controlled mode). Text set this way is not reported as the user starting a search. |
|
|
667
|
+
| `prefillText(text)` | Fill the field with text the user did not type — e.g. a query carried over from the previous page — and handle it like typing: suggestions are fetched and the text is recognized. Not reported as the user starting a search. |
|
|
652
668
|
| `setCompletedParams(params)` | Set completed params (controlled mode). |
|
|
653
669
|
| `setMode(mode)` | Switch color mode at runtime. |
|
|
654
670
|
| `update(opts)` | Update multiple options at once (e.g. `animations`, `pillPlacement`, `dropdownTrigger`, `optionsPosition`). |
|
package/dist/index.d.mts
CHANGED
|
@@ -154,6 +154,18 @@ interface MatchedItem {
|
|
|
154
154
|
* item carries `handle` instead. When both are present the strip links here.
|
|
155
155
|
*/
|
|
156
156
|
item_url?: string;
|
|
157
|
+
/**
|
|
158
|
+
* The variant a filter in the query chose for this item ("blue", "size 10"),
|
|
159
|
+
* as the platform's numeric variant id. When set, `price` and `image_url`
|
|
160
|
+
* are that variant's, and the strip links to `/products/{handle}?variant=…`
|
|
161
|
+
* so the shopper lands on it.
|
|
162
|
+
*/
|
|
163
|
+
variant_id?: string;
|
|
164
|
+
/**
|
|
165
|
+
* Whether the item can be bought: `false` is sold out. Absent when the
|
|
166
|
+
* catalog doesn't say, which is not the same as sold out.
|
|
167
|
+
*/
|
|
168
|
+
available?: boolean;
|
|
157
169
|
}
|
|
158
170
|
/** The items the applied filters left standing. */
|
|
159
171
|
interface MatchedItems {
|
|
@@ -352,6 +364,12 @@ interface Product {
|
|
|
352
364
|
/** Pre-formatted by the integration, which is the side that knows the currency. */
|
|
353
365
|
price?: string;
|
|
354
366
|
vendor?: string;
|
|
367
|
+
/**
|
|
368
|
+
* `false` marks the card sold out: a "Sold out" badge over the image, and
|
|
369
|
+
* the image desaturated. The card stays selectable. Absent or `true` shows no
|
|
370
|
+
* badge — leave it out when availability is unknown.
|
|
371
|
+
*/
|
|
372
|
+
available?: boolean;
|
|
355
373
|
}
|
|
356
374
|
/**
|
|
357
375
|
* How the product strip lays its cards out. `"row"` is the horizontally
|
|
@@ -1099,6 +1117,21 @@ declare class AIAutocomplete {
|
|
|
1099
1117
|
private resetAfterSubmit;
|
|
1100
1118
|
destroy(): void;
|
|
1101
1119
|
setMode(mode: AppearanceMode): void;
|
|
1120
|
+
/**
|
|
1121
|
+
* Fill the field with text the shopper did not type — a query carried over
|
|
1122
|
+
* from the previous page, say — and handle it as if typed: suggestions are
|
|
1123
|
+
* fetched and the text is re-identified. Unlike typing, it does not count as
|
|
1124
|
+
* the shopper starting a search.
|
|
1125
|
+
*/
|
|
1126
|
+
prefillText(text: string): void;
|
|
1127
|
+
/**
|
|
1128
|
+
* Reports `search_started` once per session, when the shopper (not the
|
|
1129
|
+
* consumer) first puts something in an empty field: typing, or picking an
|
|
1130
|
+
* option. Decided at the call, not in a store subscriber: a consumer write
|
|
1131
|
+
* made from inside a listener is delivered after its call returns, so a
|
|
1132
|
+
* subscriber cannot tell whose write it is.
|
|
1133
|
+
*/
|
|
1134
|
+
private noteSearchStarted;
|
|
1102
1135
|
setValue(text: string): void;
|
|
1103
1136
|
setCompletedParams(params: CompletedParamState[]): void;
|
|
1104
1137
|
setActivePill(index: number): void;
|
|
@@ -1215,6 +1248,7 @@ declare class AIAutocomplete {
|
|
|
1215
1248
|
*/
|
|
1216
1249
|
selectProduct(product: Product): void;
|
|
1217
1250
|
handleTextChange(value: string): void;
|
|
1251
|
+
private applyTextChange;
|
|
1218
1252
|
/** Page the datepicker back one month. No-op unless a date pill is active. */
|
|
1219
1253
|
showPreviousMonth(): void;
|
|
1220
1254
|
/** Page the datepicker forward one month. No-op unless a date pill is active. */
|
|
@@ -1282,6 +1316,7 @@ declare class AIAutocomplete {
|
|
|
1282
1316
|
on<E extends keyof AIAutocompleteEvents>(event: E, callback: (...args: AIAutocompleteEvents[E]) => void): () => void;
|
|
1283
1317
|
update(opts: CoreUpdateOptions): void;
|
|
1284
1318
|
selectOption(option: SuggestionOption): void;
|
|
1319
|
+
private applyOption;
|
|
1285
1320
|
private startSelectionAnimationTimer;
|
|
1286
1321
|
private resolveVisitorId;
|
|
1287
1322
|
private resolveSource;
|
|
@@ -1737,6 +1772,36 @@ declare function getCursorOffset(root: HTMLElement): number | null;
|
|
|
1737
1772
|
* get the browser's own scroll-to-caret behaviour.
|
|
1738
1773
|
*/
|
|
1739
1774
|
declare function setCursorOffset(root: HTMLElement, offset: number): void;
|
|
1775
|
+
/**
|
|
1776
|
+
* The chip a tap or click landed on, or null.
|
|
1777
|
+
*
|
|
1778
|
+
* Re-edit otherwise starts only from `selectionchange`, i.e. from wherever
|
|
1779
|
+
* the browser put the caret — which on touch devices is frequently not the
|
|
1780
|
+
* chip the finger was on. iOS Safari snaps a tap's caret to a word boundary
|
|
1781
|
+
* and, on the tap that focuses the field, commonly parks it at the end of the
|
|
1782
|
+
* text: inside the last chip when the input ends with one. The event target
|
|
1783
|
+
* is the element actually hit, so a tap anywhere on the chip, edges and
|
|
1784
|
+
* padding included, selects it.
|
|
1785
|
+
*
|
|
1786
|
+
* Both chip kinds report, matching the selectionchange path: the core decides
|
|
1787
|
+
* what a tap means (a completed param re-opens its options, an identified date
|
|
1788
|
+
* opens the calendar, anything else is inert).
|
|
1789
|
+
*
|
|
1790
|
+
* Returns null when the gesture left a range selection (a drag-select that
|
|
1791
|
+
* ends on a chip is a selection, not a tap).
|
|
1792
|
+
*/
|
|
1793
|
+
declare function chipIdFromTap(root: HTMLElement, target: EventTarget | null): string | null;
|
|
1794
|
+
/**
|
|
1795
|
+
* After a tap on a chip, make sure the caret is on that chip.
|
|
1796
|
+
*
|
|
1797
|
+
* The browser may have put the tap's caret somewhere else entirely (see
|
|
1798
|
+
* `chipIdFromTap`). Left there, the next `selectionchange` reads it as the
|
|
1799
|
+
* caret leaving the chip — or entering a different one — and closes or
|
|
1800
|
+
* redirects what the tap just opened. A caret already within the chip's
|
|
1801
|
+
* bounds (edges included) is left alone; otherwise it moves to the chip's
|
|
1802
|
+
* start, which every edit range includes.
|
|
1803
|
+
*/
|
|
1804
|
+
declare function keepCaretOnChip(root: HTMLElement, paramId: string): void;
|
|
1740
1805
|
/**
|
|
1741
1806
|
* True when the caret offset equals the editable's plain-text length —
|
|
1742
1807
|
* meaning the only content to the right is non-editable (e.g. trailing pills).
|
|
@@ -2134,9 +2199,10 @@ declare const PRODUCT_PATH_PREFIX = "/products/";
|
|
|
2134
2199
|
* `customFields` gets the same cards the built-in one draws.
|
|
2135
2200
|
*
|
|
2136
2201
|
* The link is the item's own `item_url` when the catalog named one, else the
|
|
2137
|
-
* `/products/{handle}` path a Shopify item implies
|
|
2138
|
-
* yields a card without a
|
|
2139
|
-
* `onProductSelect`, just nothing for
|
|
2202
|
+
* `/products/{handle}` path a Shopify item implies, opened on the chosen
|
|
2203
|
+
* variant when there is one. An item with neither yields a card without a
|
|
2204
|
+
* `url`: still activatable, still emitting `onProductSelect`, just nothing for
|
|
2205
|
+
* cmd-click to open.
|
|
2140
2206
|
*/
|
|
2141
2207
|
declare function productFromMatchedItem(item: MatchedItem): Product;
|
|
2142
2208
|
/**
|
|
@@ -2252,4 +2318,4 @@ interface SubmitResultExtras {
|
|
|
2252
2318
|
*/
|
|
2253
2319
|
declare function buildSubmitResult(text: string, completedParams: CompletedParamState[], skippedParams?: SkippedParamState[], extras?: SubmitResultExtras): AutocompleteResult;
|
|
2254
2320
|
|
|
2255
|
-
export { AIAutocomplete, type APIConfig, type APIKeyConfig, ATTRIBUTION_URL, type AccessTokenConfig, type AccessTokenResult, type AppearanceMode, type AutocompleteRequest, type AutocompleteResponse, type AutocompleteResult, type CompletedParam, type CompletedParamState, type CoreOptions, type CoreState, type CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, type DateMonthView, type DateRange, type DateSelection, type ExpressedFilter, type FilterOp, type FormatType, type IdentifiedParam, type IdentifiedParamState, type InputItem, type LooseDateOptions, type MatchedItem, type MatchedItems, ModeController, OPTIONS_GRID_MOBILE_QUERY, OPTION_ENTER_DELAY_VAR, OPTION_ENTER_FADE_MS, OPTION_ENTER_RISE_MS, OPTION_ENTER_RISE_PX, OPTION_ENTER_STAGGER_MS, type OptionOverride, type OptionOverrides, type OptionsGridLayout, type OptionsGridPlan, PLACEHOLDER_FADE_OUT_MS, PLACEHOLDER_LEAVING_ATTR, PLACEHOLDER_SWAP_GAP_MS, PLACEHOLDER_TYPE_MS, PLACEHOLDER_WORD_PAUSE_MS, PRODUCT_PATH_PREFIX, PRODUCT_ROW_PX_PER_LINE, type Product, type ProductImageFallback, type ProductRowMetrics, type ProductRowWheel, type ProductsConfig, type ProductsLayout, RANGE_SEPARATOR, type RecentlySuggested, type RenderMode, SCROLL_ARROW_ATTR, SCROLL_ARROW_BOTTOM_VAR, SCROLL_ARROW_CLASS, SCROLL_ARROW_FADE_MS, SCROLL_ARROW_LABEL, SCROLL_ARROW_SCROLL_IDLE_MS, SCROLL_ARROW_VISIBLE_ATTR, SKIPPED_PARAM_TEXT, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SkippedParamState, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type TaskKind, WEEKDAY_LABELS, addMonths, attachProductRowWheel, attachScrollArrow, buildAttributionUrl, buildDateOptions, buildQuery, buildSubmitResult, cellDay, cellIso, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateSelectionFor, extractPlainText, formatAbsoluteDate, formatDate, formatDateRange, formatOptionCount, getCursorOffset, getFooterHint, identifiedParamLabel, isCalendarFormat, isOptionsGridMobileViewport, isoDate, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, optionCountLabel, optionEnterDelayMs, optionHasImage, optionImageSrc, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, parseDate, parseLooseDate, parseLooseDateRange, plainTextLength, planOptionsGrid, previousGraphemeBoundary, productFromMatchedItem, productInitial, productRowWheelTarget, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, toWireIdentifiedParams, visibleDateRange, withSkippedParams };
|
|
2321
|
+
export { AIAutocomplete, type APIConfig, type APIKeyConfig, ATTRIBUTION_URL, type AccessTokenConfig, type AccessTokenResult, type AppearanceMode, type AutocompleteRequest, type AutocompleteResponse, type AutocompleteResult, type CompletedParam, type CompletedParamState, type CoreOptions, type CoreState, type CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, type DateMonthView, type DateRange, type DateSelection, type ExpressedFilter, type FilterOp, type FormatType, type IdentifiedParam, type IdentifiedParamState, type InputItem, type LooseDateOptions, type MatchedItem, type MatchedItems, ModeController, OPTIONS_GRID_MOBILE_QUERY, OPTION_ENTER_DELAY_VAR, OPTION_ENTER_FADE_MS, OPTION_ENTER_RISE_MS, OPTION_ENTER_RISE_PX, OPTION_ENTER_STAGGER_MS, type OptionOverride, type OptionOverrides, type OptionsGridLayout, type OptionsGridPlan, PLACEHOLDER_FADE_OUT_MS, PLACEHOLDER_LEAVING_ATTR, PLACEHOLDER_SWAP_GAP_MS, PLACEHOLDER_TYPE_MS, PLACEHOLDER_WORD_PAUSE_MS, PRODUCT_PATH_PREFIX, PRODUCT_ROW_PX_PER_LINE, type Product, type ProductImageFallback, type ProductRowMetrics, type ProductRowWheel, type ProductsConfig, type ProductsLayout, RANGE_SEPARATOR, type RecentlySuggested, type RenderMode, SCROLL_ARROW_ATTR, SCROLL_ARROW_BOTTOM_VAR, SCROLL_ARROW_CLASS, SCROLL_ARROW_FADE_MS, SCROLL_ARROW_LABEL, SCROLL_ARROW_SCROLL_IDLE_MS, SCROLL_ARROW_VISIBLE_ATTR, SKIPPED_PARAM_TEXT, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SkippedParamState, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type TaskKind, WEEKDAY_LABELS, addMonths, attachProductRowWheel, attachScrollArrow, buildAttributionUrl, buildDateOptions, buildQuery, buildSubmitResult, cellDay, cellIso, chipIdFromTap, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateSelectionFor, extractPlainText, formatAbsoluteDate, formatDate, formatDateRange, formatOptionCount, getCursorOffset, getFooterHint, identifiedParamLabel, isCalendarFormat, isOptionsGridMobileViewport, isoDate, keepCaretOnChip, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, optionCountLabel, optionEnterDelayMs, optionHasImage, optionImageSrc, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, parseDate, parseLooseDate, parseLooseDateRange, plainTextLength, planOptionsGrid, previousGraphemeBoundary, productFromMatchedItem, productInitial, productRowWheelTarget, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, toWireIdentifiedParams, visibleDateRange, withSkippedParams };
|
package/dist/index.d.ts
CHANGED
|
@@ -154,6 +154,18 @@ interface MatchedItem {
|
|
|
154
154
|
* item carries `handle` instead. When both are present the strip links here.
|
|
155
155
|
*/
|
|
156
156
|
item_url?: string;
|
|
157
|
+
/**
|
|
158
|
+
* The variant a filter in the query chose for this item ("blue", "size 10"),
|
|
159
|
+
* as the platform's numeric variant id. When set, `price` and `image_url`
|
|
160
|
+
* are that variant's, and the strip links to `/products/{handle}?variant=…`
|
|
161
|
+
* so the shopper lands on it.
|
|
162
|
+
*/
|
|
163
|
+
variant_id?: string;
|
|
164
|
+
/**
|
|
165
|
+
* Whether the item can be bought: `false` is sold out. Absent when the
|
|
166
|
+
* catalog doesn't say, which is not the same as sold out.
|
|
167
|
+
*/
|
|
168
|
+
available?: boolean;
|
|
157
169
|
}
|
|
158
170
|
/** The items the applied filters left standing. */
|
|
159
171
|
interface MatchedItems {
|
|
@@ -352,6 +364,12 @@ interface Product {
|
|
|
352
364
|
/** Pre-formatted by the integration, which is the side that knows the currency. */
|
|
353
365
|
price?: string;
|
|
354
366
|
vendor?: string;
|
|
367
|
+
/**
|
|
368
|
+
* `false` marks the card sold out: a "Sold out" badge over the image, and
|
|
369
|
+
* the image desaturated. The card stays selectable. Absent or `true` shows no
|
|
370
|
+
* badge — leave it out when availability is unknown.
|
|
371
|
+
*/
|
|
372
|
+
available?: boolean;
|
|
355
373
|
}
|
|
356
374
|
/**
|
|
357
375
|
* How the product strip lays its cards out. `"row"` is the horizontally
|
|
@@ -1099,6 +1117,21 @@ declare class AIAutocomplete {
|
|
|
1099
1117
|
private resetAfterSubmit;
|
|
1100
1118
|
destroy(): void;
|
|
1101
1119
|
setMode(mode: AppearanceMode): void;
|
|
1120
|
+
/**
|
|
1121
|
+
* Fill the field with text the shopper did not type — a query carried over
|
|
1122
|
+
* from the previous page, say — and handle it as if typed: suggestions are
|
|
1123
|
+
* fetched and the text is re-identified. Unlike typing, it does not count as
|
|
1124
|
+
* the shopper starting a search.
|
|
1125
|
+
*/
|
|
1126
|
+
prefillText(text: string): void;
|
|
1127
|
+
/**
|
|
1128
|
+
* Reports `search_started` once per session, when the shopper (not the
|
|
1129
|
+
* consumer) first puts something in an empty field: typing, or picking an
|
|
1130
|
+
* option. Decided at the call, not in a store subscriber: a consumer write
|
|
1131
|
+
* made from inside a listener is delivered after its call returns, so a
|
|
1132
|
+
* subscriber cannot tell whose write it is.
|
|
1133
|
+
*/
|
|
1134
|
+
private noteSearchStarted;
|
|
1102
1135
|
setValue(text: string): void;
|
|
1103
1136
|
setCompletedParams(params: CompletedParamState[]): void;
|
|
1104
1137
|
setActivePill(index: number): void;
|
|
@@ -1215,6 +1248,7 @@ declare class AIAutocomplete {
|
|
|
1215
1248
|
*/
|
|
1216
1249
|
selectProduct(product: Product): void;
|
|
1217
1250
|
handleTextChange(value: string): void;
|
|
1251
|
+
private applyTextChange;
|
|
1218
1252
|
/** Page the datepicker back one month. No-op unless a date pill is active. */
|
|
1219
1253
|
showPreviousMonth(): void;
|
|
1220
1254
|
/** Page the datepicker forward one month. No-op unless a date pill is active. */
|
|
@@ -1282,6 +1316,7 @@ declare class AIAutocomplete {
|
|
|
1282
1316
|
on<E extends keyof AIAutocompleteEvents>(event: E, callback: (...args: AIAutocompleteEvents[E]) => void): () => void;
|
|
1283
1317
|
update(opts: CoreUpdateOptions): void;
|
|
1284
1318
|
selectOption(option: SuggestionOption): void;
|
|
1319
|
+
private applyOption;
|
|
1285
1320
|
private startSelectionAnimationTimer;
|
|
1286
1321
|
private resolveVisitorId;
|
|
1287
1322
|
private resolveSource;
|
|
@@ -1737,6 +1772,36 @@ declare function getCursorOffset(root: HTMLElement): number | null;
|
|
|
1737
1772
|
* get the browser's own scroll-to-caret behaviour.
|
|
1738
1773
|
*/
|
|
1739
1774
|
declare function setCursorOffset(root: HTMLElement, offset: number): void;
|
|
1775
|
+
/**
|
|
1776
|
+
* The chip a tap or click landed on, or null.
|
|
1777
|
+
*
|
|
1778
|
+
* Re-edit otherwise starts only from `selectionchange`, i.e. from wherever
|
|
1779
|
+
* the browser put the caret — which on touch devices is frequently not the
|
|
1780
|
+
* chip the finger was on. iOS Safari snaps a tap's caret to a word boundary
|
|
1781
|
+
* and, on the tap that focuses the field, commonly parks it at the end of the
|
|
1782
|
+
* text: inside the last chip when the input ends with one. The event target
|
|
1783
|
+
* is the element actually hit, so a tap anywhere on the chip, edges and
|
|
1784
|
+
* padding included, selects it.
|
|
1785
|
+
*
|
|
1786
|
+
* Both chip kinds report, matching the selectionchange path: the core decides
|
|
1787
|
+
* what a tap means (a completed param re-opens its options, an identified date
|
|
1788
|
+
* opens the calendar, anything else is inert).
|
|
1789
|
+
*
|
|
1790
|
+
* Returns null when the gesture left a range selection (a drag-select that
|
|
1791
|
+
* ends on a chip is a selection, not a tap).
|
|
1792
|
+
*/
|
|
1793
|
+
declare function chipIdFromTap(root: HTMLElement, target: EventTarget | null): string | null;
|
|
1794
|
+
/**
|
|
1795
|
+
* After a tap on a chip, make sure the caret is on that chip.
|
|
1796
|
+
*
|
|
1797
|
+
* The browser may have put the tap's caret somewhere else entirely (see
|
|
1798
|
+
* `chipIdFromTap`). Left there, the next `selectionchange` reads it as the
|
|
1799
|
+
* caret leaving the chip — or entering a different one — and closes or
|
|
1800
|
+
* redirects what the tap just opened. A caret already within the chip's
|
|
1801
|
+
* bounds (edges included) is left alone; otherwise it moves to the chip's
|
|
1802
|
+
* start, which every edit range includes.
|
|
1803
|
+
*/
|
|
1804
|
+
declare function keepCaretOnChip(root: HTMLElement, paramId: string): void;
|
|
1740
1805
|
/**
|
|
1741
1806
|
* True when the caret offset equals the editable's plain-text length —
|
|
1742
1807
|
* meaning the only content to the right is non-editable (e.g. trailing pills).
|
|
@@ -2134,9 +2199,10 @@ declare const PRODUCT_PATH_PREFIX = "/products/";
|
|
|
2134
2199
|
* `customFields` gets the same cards the built-in one draws.
|
|
2135
2200
|
*
|
|
2136
2201
|
* The link is the item's own `item_url` when the catalog named one, else the
|
|
2137
|
-
* `/products/{handle}` path a Shopify item implies
|
|
2138
|
-
* yields a card without a
|
|
2139
|
-
* `onProductSelect`, just nothing for
|
|
2202
|
+
* `/products/{handle}` path a Shopify item implies, opened on the chosen
|
|
2203
|
+
* variant when there is one. An item with neither yields a card without a
|
|
2204
|
+
* `url`: still activatable, still emitting `onProductSelect`, just nothing for
|
|
2205
|
+
* cmd-click to open.
|
|
2140
2206
|
*/
|
|
2141
2207
|
declare function productFromMatchedItem(item: MatchedItem): Product;
|
|
2142
2208
|
/**
|
|
@@ -2252,4 +2318,4 @@ interface SubmitResultExtras {
|
|
|
2252
2318
|
*/
|
|
2253
2319
|
declare function buildSubmitResult(text: string, completedParams: CompletedParamState[], skippedParams?: SkippedParamState[], extras?: SubmitResultExtras): AutocompleteResult;
|
|
2254
2320
|
|
|
2255
|
-
export { AIAutocomplete, type APIConfig, type APIKeyConfig, ATTRIBUTION_URL, type AccessTokenConfig, type AccessTokenResult, type AppearanceMode, type AutocompleteRequest, type AutocompleteResponse, type AutocompleteResult, type CompletedParam, type CompletedParamState, type CoreOptions, type CoreState, type CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, type DateMonthView, type DateRange, type DateSelection, type ExpressedFilter, type FilterOp, type FormatType, type IdentifiedParam, type IdentifiedParamState, type InputItem, type LooseDateOptions, type MatchedItem, type MatchedItems, ModeController, OPTIONS_GRID_MOBILE_QUERY, OPTION_ENTER_DELAY_VAR, OPTION_ENTER_FADE_MS, OPTION_ENTER_RISE_MS, OPTION_ENTER_RISE_PX, OPTION_ENTER_STAGGER_MS, type OptionOverride, type OptionOverrides, type OptionsGridLayout, type OptionsGridPlan, PLACEHOLDER_FADE_OUT_MS, PLACEHOLDER_LEAVING_ATTR, PLACEHOLDER_SWAP_GAP_MS, PLACEHOLDER_TYPE_MS, PLACEHOLDER_WORD_PAUSE_MS, PRODUCT_PATH_PREFIX, PRODUCT_ROW_PX_PER_LINE, type Product, type ProductImageFallback, type ProductRowMetrics, type ProductRowWheel, type ProductsConfig, type ProductsLayout, RANGE_SEPARATOR, type RecentlySuggested, type RenderMode, SCROLL_ARROW_ATTR, SCROLL_ARROW_BOTTOM_VAR, SCROLL_ARROW_CLASS, SCROLL_ARROW_FADE_MS, SCROLL_ARROW_LABEL, SCROLL_ARROW_SCROLL_IDLE_MS, SCROLL_ARROW_VISIBLE_ATTR, SKIPPED_PARAM_TEXT, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SkippedParamState, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type TaskKind, WEEKDAY_LABELS, addMonths, attachProductRowWheel, attachScrollArrow, buildAttributionUrl, buildDateOptions, buildQuery, buildSubmitResult, cellDay, cellIso, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateSelectionFor, extractPlainText, formatAbsoluteDate, formatDate, formatDateRange, formatOptionCount, getCursorOffset, getFooterHint, identifiedParamLabel, isCalendarFormat, isOptionsGridMobileViewport, isoDate, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, optionCountLabel, optionEnterDelayMs, optionHasImage, optionImageSrc, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, parseDate, parseLooseDate, parseLooseDateRange, plainTextLength, planOptionsGrid, previousGraphemeBoundary, productFromMatchedItem, productInitial, productRowWheelTarget, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, toWireIdentifiedParams, visibleDateRange, withSkippedParams };
|
|
2321
|
+
export { AIAutocomplete, type APIConfig, type APIKeyConfig, ATTRIBUTION_URL, type AccessTokenConfig, type AccessTokenResult, type AppearanceMode, type AutocompleteRequest, type AutocompleteResponse, type AutocompleteResult, type CompletedParam, type CompletedParamState, type CoreOptions, type CoreState, type CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, type DateMonthView, type DateRange, type DateSelection, type ExpressedFilter, type FilterOp, type FormatType, type IdentifiedParam, type IdentifiedParamState, type InputItem, type LooseDateOptions, type MatchedItem, type MatchedItems, ModeController, OPTIONS_GRID_MOBILE_QUERY, OPTION_ENTER_DELAY_VAR, OPTION_ENTER_FADE_MS, OPTION_ENTER_RISE_MS, OPTION_ENTER_RISE_PX, OPTION_ENTER_STAGGER_MS, type OptionOverride, type OptionOverrides, type OptionsGridLayout, type OptionsGridPlan, PLACEHOLDER_FADE_OUT_MS, PLACEHOLDER_LEAVING_ATTR, PLACEHOLDER_SWAP_GAP_MS, PLACEHOLDER_TYPE_MS, PLACEHOLDER_WORD_PAUSE_MS, PRODUCT_PATH_PREFIX, PRODUCT_ROW_PX_PER_LINE, type Product, type ProductImageFallback, type ProductRowMetrics, type ProductRowWheel, type ProductsConfig, type ProductsLayout, RANGE_SEPARATOR, type RecentlySuggested, type RenderMode, SCROLL_ARROW_ATTR, SCROLL_ARROW_BOTTOM_VAR, SCROLL_ARROW_CLASS, SCROLL_ARROW_FADE_MS, SCROLL_ARROW_LABEL, SCROLL_ARROW_SCROLL_IDLE_MS, SCROLL_ARROW_VISIBLE_ATTR, SKIPPED_PARAM_TEXT, type ScrollArrowArgs, type ScrollArrowController, type Segment, type SkippedParamState, type Store, type SubmitResultExtras, type Suggestion, type SuggestionOption, type TaskKind, WEEKDAY_LABELS, addMonths, attachProductRowWheel, attachScrollArrow, buildAttributionUrl, buildDateOptions, buildQuery, buildSubmitResult, cellDay, cellIso, chipIdFromTap, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateSelectionFor, extractPlainText, formatAbsoluteDate, formatDate, formatDateRange, formatOptionCount, getCursorOffset, getFooterHint, identifiedParamLabel, isCalendarFormat, isOptionsGridMobileViewport, isoDate, keepCaretOnChip, measureOptionsGrid, monthLabel, needsOptionsGridMeasurement, optionCountLabel, optionEnterDelayMs, optionHasImage, optionImageSrc, optionLabel, optionsEntranceDurationMs, optionsGridTemplateColumns, parseDate, parseLooseDate, parseLooseDateRange, plainTextLength, planOptionsGrid, previousGraphemeBoundary, productFromMatchedItem, productInitial, productRowWheelTarget, productsFromCustomFields, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, toWireIdentifiedParams, visibleDateRange, withSkippedParams };
|