@magicx-eng/ai-autocomplete-vanilla 0.75.1 → 0.76.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 +7 -2
- package/REFERENCE.md +100 -1
- package/dist/index.d.mts +100 -4
- package/dist/index.d.ts +100 -4
- package/dist/index.js +115 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +115 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -179,7 +179,8 @@ Product display options apply to both `renderMode: "full"` and
|
|
|
179
179
|
|---|---|---|---|
|
|
180
180
|
| `showProducts?` | `boolean` | `true` | Show product cards whenever there are products to display. |
|
|
181
181
|
| `productsLayout?` | `"row" \| "list"` | `"row"` | Lay out cards as a scrolling row or a vertical list. |
|
|
182
|
-
| `seeAllResults?` | `boolean` | `false` | Tier 1 only (React's `<AIAutocomplete>` has it too). End the dropdown in a "See all results" button that submits like Enter, shown while there is typed text. The dropdown then keeps its full width at every step. |
|
|
182
|
+
| `seeAllResults?` | `boolean` | `false` | Tier 1 only (React's `<AIAutocomplete>` has it too). End the dropdown in a "See all results" button that submits like Enter, shown while there is typed text. The dropdown then keeps its full width at every step. It shows a spinner while its submit is in progress. |
|
|
183
|
+
| `submitProgress?` | `boolean` | `true` | Show a spinner and ignore repeats on a submit or product tap while your page loads. `false` turns it off. See "While your page loads" in REFERENCE.md. |
|
|
183
184
|
| `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). |
|
|
184
185
|
| `showProductVendor?` | `boolean` | `true` | Whether product cards draw the product's `vendor` as a line above the title. Set to `false` when your product titles already name the brand, so a card does not show it twice. See [Product strip](#product-strip). |
|
|
185
186
|
|
|
@@ -211,6 +212,10 @@ ac.getRequestId(); // The latest applied /suggest request ID, or nul
|
|
|
211
212
|
|
|
212
213
|
> **Caret placement after a completion** — whenever a completed param is added (by any means — option click, exact-match typing, or re-edit), the caret lands right after the trailing space following the bold so typing can continue immediately. A space is inserted if one wasn't already there.
|
|
213
214
|
|
|
215
|
+
### While your page loads
|
|
216
|
+
|
|
217
|
+
A submit (Enter, the arrow, "See all results") and a product card tap show a spinner and ignore repeats until your page takes over. Details, `isSubmitting` and `holdSubmit()`: [REFERENCE.md](https://unpkg.com/@magicx-eng/ai-autocomplete-vanilla/REFERENCE.md), under "While your page loads".
|
|
218
|
+
|
|
214
219
|
### Product strip
|
|
215
220
|
|
|
216
221
|
The dropdown shows a row of product cards under the options whenever there are products to show. By default they are the items the `/suggest` response reports as matching the query. When a card is picked, `onProductSelect` fires; the SDK never navigates. `showProducts: false` turns the strip off, `productsLayout: "list"` stacks the cards as rows, and `productImageFallback` sets what a card shows when it has no image. The full guide, with the `Product` shape, sold-out badges and accessibility, is in [REFERENCE.md](https://unpkg.com/@magicx-eng/ai-autocomplete-vanilla/REFERENCE.md), under "Product strip".
|
|
@@ -568,7 +573,7 @@ Styles are auto-injected at runtime (Tier 1 and Tier 2). No CSS import needed. T
|
|
|
568
573
|
|
|
569
574
|
Every class name the core emits is namespaced — `magicx-aia-*` (plus the bare `magicx-aia` root) and `aia-*` for the layout primitives — so nothing it renders can match a `.container`, `.pill` or `.dropdown` rule in your own stylesheet, and none of its rules can reach your elements.
|
|
570
575
|
|
|
571
|
-
**Page CSS stops at the widget's edge.** Everything inside the input wrapper (`[data-aia-input-wrapper]`) and the dropdown (`[data-aia-dropdown]`) is reset to browser defaults before the SDK's own styles apply, so element and universal rules
|
|
576
|
+
**Page CSS stops at the widget's edge.** Everything inside the input wrapper (`[data-aia-input-wrapper]`) and the dropdown (`[data-aia-dropdown]`) is reset to browser defaults before the SDK's own styles apply, so element and universal rules — `button { … }`, `a { … }`, `* { … }`, a CSS reset, a framework's preflight — never reach it, and inherited typography adjustments (line-height, letter-spacing, text-transform, text-align, …) are pinned at those two roots. Font family, size, weight and text colour still inherit from your page, and a submit button you provide is left to your own stylesheet. The SDK's inline icons are covered too: a page's `svg { display: block; max-width: 100%; margin: … }` or `svg { width: 100%; fill: currentColor }` leaves the submit arrow, the scroll chevron and the option icons as drawn. The reset sits at specificity (0,0,5), below any rule that names a class, attribute, id or pseudo-class: your `data-aia-*` overrides win, and so does a page rule like `.sidebar button { … }`: scope those to your own markup. A page-wide `:focus-visible` ring still reaches the widget's buttons but never its editor; to show focus on the field, set `--aia-focus-ring`. For complete isolation, including class-scoped page rules, mount the widget in a shadow root — see [Shadow DOM](#shadow-dom).
|
|
572
577
|
|
|
573
578
|
### Shadow DOM
|
|
574
579
|
|
package/REFERENCE.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Longer guides that do not fit in the [README](https://unpkg.com/@magicx-eng/ai-autocomplete-vanilla/README.md) on the npm page. This file ships in the package, at `node_modules/@magicx-eng/ai-autocomplete-vanilla/REFERENCE.md`.
|
|
4
4
|
|
|
5
5
|
- [Product strip](#product-strip)
|
|
6
|
+
- [While your page loads](#while-your-page-loads)
|
|
6
7
|
- [Datepicker](#datepicker)
|
|
7
8
|
- [Time picker](#time-picker)
|
|
8
9
|
- [Multiple selections](#multiple-selections)
|
|
@@ -307,6 +308,98 @@ rides that one scheduler and changing the config doesn't itself change the
|
|
|
307
308
|
query. `update({ products: undefined })` hands the strip back to the server's
|
|
308
309
|
items at once, and `update({ showProducts })` empties or restores it at once.
|
|
309
310
|
|
|
311
|
+
## While your page loads
|
|
312
|
+
|
|
313
|
+
A submit and a tap on a product card usually hand the shopper off to a page of your own, which can take a few seconds to load, on a phone especially. Until it does, the control that was pressed shows that the tap took, and a repeat of the same tap is ignored. This is on by default (`submitProgress`).
|
|
314
|
+
|
|
315
|
+
**What shows**
|
|
316
|
+
|
|
317
|
+
- **A submit**, by Enter (or the keyboard's Go), the arrow button, or "See all results": the arrow button shows a spinner in place of the arrow, and "See all results" shows one beside its label. Both keep their size, stay enabled and carry `aria-busy="true"`. `getState().isSubmitting` is `true` meanwhile, in every tier.
|
|
318
|
+
- **A product card**: the tapped card shows a spinner over its picture and carries `aria-busy="true"`. With no `onProductSelect` (and no `productSelect` listener) a card tap marks nothing. `getState().selectingProductId` holds its `id`.
|
|
319
|
+
|
|
320
|
+
**What is ignored meanwhile**
|
|
321
|
+
|
|
322
|
+
Only a repeat of the same thing, so one tap is one `onSubmit` or `onProductSelect` call:
|
|
323
|
+
|
|
324
|
+
- while a submit is in progress, another submit by any route (Enter (or the keyboard's Go), the arrow button, or "See all results");
|
|
325
|
+
- while a product selection is in progress, another tap (or Enter / Space) on that same card.
|
|
326
|
+
|
|
327
|
+
Nothing else is held back. A tap on a different product card goes through at once and that card becomes the busy one. A cmd/ctrl-click or middle-click on a card still opens the link in a new tab and marks nothing. The add-to-cart button keeps its own spinner, and picking an option is unaffected.
|
|
328
|
+
|
|
329
|
+
**Every way it ends**, whichever comes first:
|
|
330
|
+
|
|
331
|
+
- **a promise your handler returned settles**, resolved or rejected. Return one from `onSubmit` / `onProductSelect` when the work stays on the page (inline results, a quick view), so the spinner lasts exactly as long as the work. A rejection is still reported to the page as an unhandled rejection unless you catch it;
|
|
332
|
+
- **the input changes**: typed text, a chip added or removed, `reset()`. A product selection also ends when the products change. With `resetOnSubmit` on (the Tier 1 default) the field clears right after `onSubmit`, so a submit is never marked and no spinner is drawn;
|
|
333
|
+
- **the shopper interacts with something else**: a press (`pointerdown`) or a key anywhere on the page outside the busy control. Once they are doing something else the page did not leave, so the spinner is stale: a quick view your handler opened clears the card's spinner at the first tap inside it, and inline results clear the submit's at the first tap or key elsewhere. Keys in the widget's own input do not count (typing there already ends it by the rule above);
|
|
334
|
+
- **you end it**: `ac.endSubmitProgress()`, for when the work your handler started is done;
|
|
335
|
+
- **the page is shown again from the back/forward cache**, so a shopper who presses Back never finds a spinner still turning;
|
|
336
|
+
- **8 seconds pass**, for a handler that neither navigates nor does any of the above.
|
|
337
|
+
|
|
338
|
+
The spinner turns slower under `prefers-reduced-motion`.
|
|
339
|
+
|
|
340
|
+
Four things to know about those rules:
|
|
341
|
+
|
|
342
|
+
- Touch counts as interacting. A finger put down to scroll the page is a `pointerdown` like any other, so scrolling ends the wait.
|
|
343
|
+
- The repeat guard needs to see where a press landed. Inside a closed shadow root it cannot (an open one is fine), so there a repeat press ends the wait and goes through as a new one.
|
|
344
|
+
- A repeat Enter on an unchanged query is ignored while a submit is in progress, like a repeat press on the arrow.
|
|
345
|
+
- If you both return a promise and catch its rejection yourself, the page sees one extra `unhandledrejection` for it: return the caught promise instead (`return work.catch(report)`).
|
|
346
|
+
|
|
347
|
+
**Custom submit buttons**
|
|
348
|
+
|
|
349
|
+
A `submitButton` element you pass in is marked the same way as the built-in arrow: it carries `data-aia-submit-state="busy"` and `aria-busy="true"` while a submit is in progress (it already carries `data-aia-submit` and `data-aia-submit-slot`), and a press on it is ignored meanwhile. The SDK draws nothing on it; style the state yourself, for example `[data-aia-submit-slot][data-aia-submit-state="busy"] { opacity: 0.6; }`. A button you render outside the widget (Tier 2 or 3) is yours entirely: read `getState().isSubmitting` (or subscribe) to show the state.
|
|
350
|
+
|
|
351
|
+
If you render your own submit button (Tier 2 or 3): skip the submit while `getState().isSubmitting` is `true`, call `ac.holdSubmit(returned)` right after your handler with what it returned, and put `data-aia-submit` on the button so a press on it counts as the repeat rather than as the shopper moving on. Your own product cards likewise: `data-aia-product`, and `data-aia-product-state="busy"` on the one whose `id` is `selectingProductId`.
|
|
352
|
+
|
|
353
|
+
| | |
|
|
354
|
+
|---|---|
|
|
355
|
+
| `getState().isSubmitting` | `boolean`. A submit is in progress. |
|
|
356
|
+
| `getState().selectingProductId` | `string \| null`. The `id` of the product whose selection is in progress, else `null`. |
|
|
357
|
+
| `ac.holdSubmit(returned?)` | Mark a submit you ran from your own button as in progress. Enter and the built-in buttons are marked for you. Calling it from inside `onSubmit` with a promise of your own also works, for a handler that cannot return one. |
|
|
358
|
+
| `ac.endSubmitProgress()` | End whatever is in progress, a submit or a product selection, now. |
|
|
359
|
+
|
|
360
|
+
### Turning it off
|
|
361
|
+
|
|
362
|
+
`submitProgress: false` turns all of it off for that instance, together: nothing is marked busy, no `aria-busy` is set, and every press calls your handler again. `isSubmitting` stays `false`, `selectingProductId` stays `null` and `holdSubmit()` does nothing. `ac.update({ submitProgress })` switches it at any time; turning it off ends whatever was in progress.
|
|
363
|
+
|
|
364
|
+
If your page shows its results inline, leave it on and return a promise from `onSubmit` (and from `onProductSelect`) that settles when the results are on screen: the spinner then lasts exactly as long as the work, with no 8 second wait.
|
|
365
|
+
|
|
366
|
+
### Styling the spinner
|
|
367
|
+
|
|
368
|
+
Each control carries a state attribute while it is busy, plus `aria-busy="true"`. The attributes are the stable styling hooks, the same in the vanilla, React and Angular packages; class names are not. The spinner is a pseudo-element:
|
|
369
|
+
|
|
370
|
+
| Place | Busy selector | Spinner |
|
|
371
|
+
|---|---|---|
|
|
372
|
+
| The arrow button | `[data-aia-submit][data-aia-submit-state="busy"]` | its `::after`; the arrow is its `svg`, hidden meanwhile |
|
|
373
|
+
| "See all results" | `[data-aia-see-all] [data-aia-see-all-state="busy"]` | its `::after` |
|
|
374
|
+
| The tapped product card | `[data-aia-product][data-aia-product-state="busy"]` | `[data-aia-product-media]::before` inside it |
|
|
375
|
+
|
|
376
|
+
These variables restyle it; today's look is each one's fallback. Set them on the widget's container or any ancestor.
|
|
377
|
+
|
|
378
|
+
| Variable | Default | What it sets |
|
|
379
|
+
|---|---|---|
|
|
380
|
+
| `--aia-spinner-size` | `16px` | The spinner's diameter, in every place. |
|
|
381
|
+
| `--aia-spinner-width` | `2px` | Its stroke width, in every place. |
|
|
382
|
+
| `--aia-submit-spinner-color` | `currentColor` (the arrow's colour) | The spinner on the arrow button. |
|
|
383
|
+
| `--aia-see-all-spinner-color` | `currentColor` (the label's colour) | The spinner beside "See all results". |
|
|
384
|
+
| `--aia-product-spinner-color` | `--aia-product-cart-color`, then `#1f2328` | The arc on a product card. |
|
|
385
|
+
| `--aia-product-spinner-bg` | `--aia-product-cart-bg`, then `rgba(255, 255, 255, 0.94)` | The disc behind that arc. |
|
|
386
|
+
|
|
387
|
+
To hide the spinner and keep the behaviour (repeats still ignored, `aria-busy` still set), use CSS alone. The SDK's own rules add no specificity for the busy state, so these win whatever order the stylesheets load in:
|
|
388
|
+
|
|
389
|
+
```css
|
|
390
|
+
[data-aia-submit][data-aia-submit-state="busy"]::after,
|
|
391
|
+
[data-aia-see-all] [data-aia-see-all-state="busy"]::after,
|
|
392
|
+
[data-aia-product][data-aia-product-state="busy"] [data-aia-product-media]::before {
|
|
393
|
+
display: none;
|
|
394
|
+
}
|
|
395
|
+
/* Keep the arrow on show in place of its spinner. */
|
|
396
|
+
[data-aia-submit][data-aia-submit-state="busy"] svg {
|
|
397
|
+
display: block;
|
|
398
|
+
}
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
The same selectors take any other rule, for a look of your own: a dimmed card (`[data-aia-product][data-aia-product-state="busy"] { opacity: 0.6; }`), a different animation, a label change.
|
|
402
|
+
|
|
310
403
|
## Datepicker
|
|
311
404
|
|
|
312
405
|
When the next parameter is a date, the dropdown shows a calendar instead of a
|
|
@@ -611,10 +704,16 @@ The full input also accepts `--aia-input-radius` and `--aia-written-text-font-we
|
|
|
611
704
|
| `--aia-multi-done-bg` / `--aia-multi-done-bg-hover` / `--aia-multi-done-color` | `--aia-done-*` | `--aia-done-*` | Override the multi-select Done button alone. |
|
|
612
705
|
| `--aia-multi-done-bg-beside-see-all` / `--aia-multi-done-color-beside-see-all` | `transparent` / `--aia-option-color-selected` | `transparent` / `--aia-option-color-selected` | The multi-select Done button's fill and label colour at rest while "See all results" is shown under it, so the two do not compete (hover keeps `--aia-multi-done-bg-hover` and the Done colour). `--aia-multi-done-bg` and `--aia-done-bg` do not apply in this state. |
|
|
613
706
|
| `--aia-multi-done-width` | `100%` (classic: as wide as the widest option) | same | Width of the multi-select Done button. |
|
|
614
|
-
| `--aia-panel-min-width` | `160px` | same | Narrowest the floating options box gets when it hugs its options (desktop). |
|
|
707
|
+
| `--aia-panel-min-width` | `160px` | same | Narrowest the floating options box gets when it hugs its options (desktop). Set `100%` to turn the hug off: the box then stays as wide as the field, up to `--aia-dropdown-max-width`. |
|
|
708
|
+
| `--aia-dropdown-max-width` | `544px` | same | Widest the floating options box gets. `none` lets it span the whole field (with `--aia-panel-min-width: 100%`, it always does). The calendar and the time wheel keep `--aia-date-panel-width` and `--aia-time-panel-width`. |
|
|
709
|
+
| `--aia-focus-ring` | `none` | same | Outline drawn around the whole field while it has focus, e.g. `2px solid #1668e3`. Off by default. The editor inside never draws a ring of its own, whatever your page's `:focus-visible` rule says, so this is where focus shows. |
|
|
710
|
+
| `--aia-focus-ring-offset` | `0px` | same | Gap between that ring and the field's border; negative draws it over the border. |
|
|
615
711
|
| `--aia-multi-done-min-width` | `120px` | `120px` | Narrowest the multi-select Done button gets. |
|
|
616
712
|
| `--aia-time-done-bg` / `--aia-time-done-bg-hover` / `--aia-time-done-color` | `--aia-done-*` | `--aia-done-*` | Override the time wheel's Done button alone. |
|
|
617
713
|
| `--aia-see-all-bg` / `--aia-see-all-bg-hover` / `--aia-see-all-color` | `#2b2b2b` / `#3d3d3d` / `#ffffff` | `--aia-confirm-*` | The "See all results" button (`seeAllResults`). |
|
|
714
|
+
| `--aia-spinner-size` / `--aia-spinner-width` | `16px` / `2px` | same | The spinner a submit or product tap shows while your page loads: its diameter and stroke width. See "While your page loads". |
|
|
715
|
+
| `--aia-submit-spinner-color` / `--aia-see-all-spinner-color` | `currentColor` | same | That spinner on the arrow button and beside "See all results". |
|
|
716
|
+
| `--aia-product-spinner-color` / `--aia-product-spinner-bg` | `--aia-product-cart-color` / `--aia-product-cart-bg` | same | That spinner's arc and disc on a product card. |
|
|
618
717
|
| `--aia-see-all-height` / `--aia-see-all-radius` / `--aia-see-all-font-size` | `48px` / `12px` / `16px` | same | Its minimum height, corner radius and text size. |
|
|
619
718
|
| `--aia-location-field-bg-idle` | `transparent` | `transparent` | The location search field at rest. |
|
|
620
719
|
| `--aia-location-field-bg` | `--aia-streak-rgb` at 6% (indigo) | `--aia-streak-rgb` at 6% (white) | The location search field on hover or focus. |
|
package/dist/index.d.mts
CHANGED
|
@@ -1053,6 +1053,23 @@ interface CoreInputState {
|
|
|
1053
1053
|
* the panel nor tells the consumer the widget lost focus.
|
|
1054
1054
|
*/
|
|
1055
1055
|
locationFieldFocused: boolean;
|
|
1056
|
+
/**
|
|
1057
|
+
* A submit is in progress: `onSubmit` ran and the page it opens has not
|
|
1058
|
+
* taken over yet. The submit controls show a spinner and a further submit
|
|
1059
|
+
* by any route is ignored. It ends when a promise `onSubmit` returned
|
|
1060
|
+
* settles, when the input changes, when the shopper presses or types
|
|
1061
|
+
* somewhere else on the page, when the page is shown again from the
|
|
1062
|
+
* back/forward cache, on `endSubmitProgress()`, or after 8 seconds.
|
|
1063
|
+
*/
|
|
1064
|
+
isSubmitting: boolean;
|
|
1065
|
+
/**
|
|
1066
|
+
* The `id` of the product whose selection is in progress (`onProductSelect`
|
|
1067
|
+
* ran, its page has not taken over yet), else null. Its card shows a
|
|
1068
|
+
* spinner and selecting it again is ignored; another product goes through
|
|
1069
|
+
* and takes its place. It ends like `isSubmitting`, and when the products
|
|
1070
|
+
* change.
|
|
1071
|
+
*/
|
|
1072
|
+
selectingProductId: string | null;
|
|
1056
1073
|
/**
|
|
1057
1074
|
* Re-edit state: while non-null, the user is editing a bold completed param.
|
|
1058
1075
|
* The snapshot stays here even after the param is removed from
|
|
@@ -1521,6 +1538,16 @@ interface CoreOptions {
|
|
|
1521
1538
|
* Default: false.
|
|
1522
1539
|
*/
|
|
1523
1540
|
seeAllResults?: boolean;
|
|
1541
|
+
/**
|
|
1542
|
+
* When true (default), a submit and a product card tap show that they took
|
|
1543
|
+
* while the page they open loads: the submit controls and the tapped card
|
|
1544
|
+
* show a spinner, and a repeat of the same tap is ignored until it is over
|
|
1545
|
+
* (a promise the handler returned settles, the input changes, the shopper
|
|
1546
|
+
* presses or types somewhere else, the page is shown again from the
|
|
1547
|
+
* back/forward cache, or 8 seconds pass). Set to false to turn
|
|
1548
|
+
* all of it off: nothing is marked, and every press calls your handler.
|
|
1549
|
+
*/
|
|
1550
|
+
submitProgress?: boolean;
|
|
1524
1551
|
/**
|
|
1525
1552
|
* How the product strip lays its cards out. `"row"` (the default) is a
|
|
1526
1553
|
* horizontally scrolling shelf of cards. `"list"` stacks the same cards as
|
|
@@ -1558,8 +1585,13 @@ interface CoreOptions {
|
|
|
1558
1585
|
* A throw or a result that is not an array keeps the SDK's cards.
|
|
1559
1586
|
*/
|
|
1560
1587
|
mapProducts?: (products: Product[], items: MatchedItem[]) => Product[];
|
|
1561
|
-
/**
|
|
1562
|
-
|
|
1588
|
+
/**
|
|
1589
|
+
* Called when the user submits (Enter, or the submit button in Tier 1).
|
|
1590
|
+
* Until the page it opens takes over, the submit is in progress
|
|
1591
|
+
* (`isSubmitting`): return a promise to say when it is over, for a submit
|
|
1592
|
+
* that stays on the page.
|
|
1593
|
+
*/
|
|
1594
|
+
onSubmit?: (result: AutocompleteResult) => void | PromiseLike<unknown>;
|
|
1563
1595
|
/**
|
|
1564
1596
|
* Called after every successful suggestion round-trip with the structured
|
|
1565
1597
|
* query as the SDK now understands it — the same `AutocompleteResult` shape
|
|
@@ -1588,7 +1620,7 @@ interface CoreOptions {
|
|
|
1588
1620
|
* fill the input, …). Modifier / middle clicks are left to the browser so
|
|
1589
1621
|
* cmd-click and "copy link address" keep working, and don't fire this.
|
|
1590
1622
|
*/
|
|
1591
|
-
onProductSelect?: (product: Product) => void
|
|
1623
|
+
onProductSelect?: (product: Product) => void | PromiseLike<unknown>;
|
|
1592
1624
|
/**
|
|
1593
1625
|
* Adds a product to the cart from its card. When set, every card that isn't
|
|
1594
1626
|
* sold out (`available: false`) shows an add-to-cart button in the bottom
|
|
@@ -1712,6 +1744,15 @@ declare class AIAutocomplete {
|
|
|
1712
1744
|
/** Where a space-picked place left the caret, until the editor reports its own. */
|
|
1713
1745
|
private spacePickCaret;
|
|
1714
1746
|
private readonly emitSubmit;
|
|
1747
|
+
/** The submit in progress, if any: see `CoreInputState.isSubmitting`. */
|
|
1748
|
+
private readonly submitHold;
|
|
1749
|
+
/** The product selection in progress, if any: see `selectingProductId`. */
|
|
1750
|
+
private readonly productHold;
|
|
1751
|
+
/**
|
|
1752
|
+
* The keydowns the widget's own input handled. A hand-off in progress ends
|
|
1753
|
+
* when the shopper types somewhere else, and these are not somewhere else.
|
|
1754
|
+
*/
|
|
1755
|
+
private readonly ownKeys;
|
|
1715
1756
|
private readonly emitError;
|
|
1716
1757
|
constructor(container: HTMLElement, opts?: CoreOptions);
|
|
1717
1758
|
focus(): void;
|
|
@@ -1870,6 +1911,27 @@ declare class AIAutocomplete {
|
|
|
1870
1911
|
* own — a button you render — so each submit is counted once.
|
|
1871
1912
|
*/
|
|
1872
1913
|
recordSubmit(result: AutocompleteResult): void;
|
|
1914
|
+
/**
|
|
1915
|
+
* Ends whatever is in progress, a submit or a product selection, at once:
|
|
1916
|
+
* call it when the work your handler started is done and the shopper is
|
|
1917
|
+
* still on the page (a quick view opened, inline results drawn). The other
|
|
1918
|
+
* way is to return a promise from the handler.
|
|
1919
|
+
*/
|
|
1920
|
+
endSubmitProgress(): void;
|
|
1921
|
+
/** Whether Tier 1's own reset follows a submit in the same task. */
|
|
1922
|
+
private resetsAfterSubmit;
|
|
1923
|
+
/** `submitProgress`, read at call time so `update()` can flip it. */
|
|
1924
|
+
private showsProgress;
|
|
1925
|
+
/**
|
|
1926
|
+
* Marks a submit you ran yourself as in progress (`isSubmitting`), the way
|
|
1927
|
+
* the SDK marks the ones it runs (Enter, Tier 1's button): call it from a
|
|
1928
|
+
* submit button you render, right after your handler, with what the handler
|
|
1929
|
+
* returned. A promise ends it when it settles; otherwise it ends when the
|
|
1930
|
+
* input changes, when the page is shown again from the back/forward cache,
|
|
1931
|
+
* or after 8 seconds. Does nothing while a submit is already in progress,
|
|
1932
|
+
* or with `submitProgress` off.
|
|
1933
|
+
*/
|
|
1934
|
+
holdSubmit(returned?: unknown): void;
|
|
1873
1935
|
/**
|
|
1874
1936
|
* Announce a product selection. The rendered cards call this on activation;
|
|
1875
1937
|
* headless consumers rendering their own strip call it themselves.
|
|
@@ -2061,6 +2123,11 @@ declare class AIAutocomplete {
|
|
|
2061
2123
|
* only after its store write, and its own impression goes out first (the
|
|
2062
2124
|
* deferred one then matches it and is dropped).
|
|
2063
2125
|
*/
|
|
2126
|
+
/**
|
|
2127
|
+
* Ends a submit or product selection in progress once what it was started
|
|
2128
|
+
* for is no longer on screen: the input changed, or the products did.
|
|
2129
|
+
*/
|
|
2130
|
+
private subscribeHandoffHolds;
|
|
2064
2131
|
private subscribeVisibleImpression;
|
|
2065
2132
|
/**
|
|
2066
2133
|
* Records what a response put on screen: pills and their options in display
|
|
@@ -2404,6 +2471,22 @@ declare function isDimmedDay(iso: string | null, today: string, floor?: string |
|
|
|
2404
2471
|
*/
|
|
2405
2472
|
declare function dateFloorFor(formatType: FormatType | undefined, rangeStart: string | null | undefined): string | null;
|
|
2406
2473
|
|
|
2474
|
+
/**
|
|
2475
|
+
* The pills the dropdown's pill bar shows.
|
|
2476
|
+
*
|
|
2477
|
+
* While the dropdown mirrors the question just answered (`dropdownSuggestion`,
|
|
2478
|
+
* from the pick until the response's options replace the faded rows), the bar
|
|
2479
|
+
* keeps that question in front of the pills still waiting. The label then
|
|
2480
|
+
* fades out in place with its rows, and the next question arrives with its
|
|
2481
|
+
* own options in one step. Without it the bar jumps to the next cached pill
|
|
2482
|
+
* the moment loading starts: a name the response may not even lead with,
|
|
2483
|
+
* shown over rows that belong to the question before it.
|
|
2484
|
+
*
|
|
2485
|
+
* `reEditPill` is the lone pill re-edit shows (the param being re-edited), or
|
|
2486
|
+
* null outside re-edit.
|
|
2487
|
+
*/
|
|
2488
|
+
declare function dropdownPillsFor(dropdownSuggestion: Suggestion | null, reEditPill: Suggestion | null, actionableSuggestions: Suggestion[]): Suggestion[];
|
|
2489
|
+
|
|
2407
2490
|
/**
|
|
2408
2491
|
* Entrance choreography for the dropdown's option rows.
|
|
2409
2492
|
*
|
|
@@ -2895,6 +2978,8 @@ declare function syncPanelHug(dropdown: HTMLElement): void;
|
|
|
2895
2978
|
* old content stays on top as a ghost that fades to transparent with a 2px
|
|
2896
2979
|
* blur over 280ms, while the new content dissolves in (opacity 0 and a 2px
|
|
2897
2980
|
* blur to clear, 320ms after a 40ms beat) on the same soft ease.
|
|
2981
|
+
* - The new content's label arrives with the dissolve alone: its own entrance
|
|
2982
|
+
* fade is cancelled for that render (see `dropEntranceFades`).
|
|
2898
2983
|
* - While a request loads, the old content has already been fading out in
|
|
2899
2984
|
* place (`data-aia-loading`, 160ms). The ghost then starts from the opacity
|
|
2900
2985
|
* that fade had reached, never back at full, and when the fade has finished
|
|
@@ -3305,6 +3390,17 @@ interface Store<S> {
|
|
|
3305
3390
|
}
|
|
3306
3391
|
declare function createStore<S>(initial: S): Store<S>;
|
|
3307
3392
|
|
|
3393
|
+
/**
|
|
3394
|
+
* What a framework wrapper's stand-in listener answers when the integration
|
|
3395
|
+
* supplied no handler of its own. The wrappers register one listener up
|
|
3396
|
+
* front, whatever the integration passed, so the core cannot tell an unhandled
|
|
3397
|
+
* selection from a handled one by counting listeners: a hand-off nobody
|
|
3398
|
+
* handles marks nothing in progress.
|
|
3399
|
+
*
|
|
3400
|
+
* @internal for the React and Angular packages.
|
|
3401
|
+
*/
|
|
3402
|
+
declare const HANDOFF_NOT_HANDLED: unique symbol;
|
|
3403
|
+
|
|
3308
3404
|
/**
|
|
3309
3405
|
* The /suggest wire format this SDK speaks, sent as `meta.schema_version` on
|
|
3310
3406
|
* every request. The server answers in the same format.
|
|
@@ -3564,4 +3660,4 @@ declare const SMART_SUGGESTION_SPARKLE_SVG: string;
|
|
|
3564
3660
|
/** True when some pill is a question the shopper can decline. */
|
|
3565
3661
|
declare function hasSkippablePill(suggestions: Suggestion[]): boolean;
|
|
3566
3662
|
|
|
3567
|
-
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, 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, 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, previousGraphemeBoundary, productFromMatchedItem, productImageSources, productImageSrc, productInitial, productPhotoFill, productRowWheelTarget, productsFromCustomFields, queryLive, releasePanelHug, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, settlePanelMorph, shopifyImageSrc, startingHintOptions, syncPanelHug, timeWheelIndex, timeWheelIndexFromScroll, timeWheelRows, toWireIdentifiedParams, typedFragment, uiStringsFor, visibleDateRange, watchEditorHeight, withSkippedParams, withTimeWheelIndex, withoutTraditionalAutocomplete };
|
|
3663
|
+
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, previousGraphemeBoundary, productFromMatchedItem, productImageSources, productImageSrc, productInitial, productPhotoFill, productRowWheelTarget, productsFromCustomFields, queryLive, releasePanelHug, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, settlePanelMorph, shopifyImageSrc, startingHintOptions, syncPanelHug, timeWheelIndex, timeWheelIndexFromScroll, timeWheelRows, toWireIdentifiedParams, typedFragment, uiStringsFor, visibleDateRange, watchEditorHeight, withSkippedParams, withTimeWheelIndex, withoutTraditionalAutocomplete };
|
package/dist/index.d.ts
CHANGED
|
@@ -1053,6 +1053,23 @@ interface CoreInputState {
|
|
|
1053
1053
|
* the panel nor tells the consumer the widget lost focus.
|
|
1054
1054
|
*/
|
|
1055
1055
|
locationFieldFocused: boolean;
|
|
1056
|
+
/**
|
|
1057
|
+
* A submit is in progress: `onSubmit` ran and the page it opens has not
|
|
1058
|
+
* taken over yet. The submit controls show a spinner and a further submit
|
|
1059
|
+
* by any route is ignored. It ends when a promise `onSubmit` returned
|
|
1060
|
+
* settles, when the input changes, when the shopper presses or types
|
|
1061
|
+
* somewhere else on the page, when the page is shown again from the
|
|
1062
|
+
* back/forward cache, on `endSubmitProgress()`, or after 8 seconds.
|
|
1063
|
+
*/
|
|
1064
|
+
isSubmitting: boolean;
|
|
1065
|
+
/**
|
|
1066
|
+
* The `id` of the product whose selection is in progress (`onProductSelect`
|
|
1067
|
+
* ran, its page has not taken over yet), else null. Its card shows a
|
|
1068
|
+
* spinner and selecting it again is ignored; another product goes through
|
|
1069
|
+
* and takes its place. It ends like `isSubmitting`, and when the products
|
|
1070
|
+
* change.
|
|
1071
|
+
*/
|
|
1072
|
+
selectingProductId: string | null;
|
|
1056
1073
|
/**
|
|
1057
1074
|
* Re-edit state: while non-null, the user is editing a bold completed param.
|
|
1058
1075
|
* The snapshot stays here even after the param is removed from
|
|
@@ -1521,6 +1538,16 @@ interface CoreOptions {
|
|
|
1521
1538
|
* Default: false.
|
|
1522
1539
|
*/
|
|
1523
1540
|
seeAllResults?: boolean;
|
|
1541
|
+
/**
|
|
1542
|
+
* When true (default), a submit and a product card tap show that they took
|
|
1543
|
+
* while the page they open loads: the submit controls and the tapped card
|
|
1544
|
+
* show a spinner, and a repeat of the same tap is ignored until it is over
|
|
1545
|
+
* (a promise the handler returned settles, the input changes, the shopper
|
|
1546
|
+
* presses or types somewhere else, the page is shown again from the
|
|
1547
|
+
* back/forward cache, or 8 seconds pass). Set to false to turn
|
|
1548
|
+
* all of it off: nothing is marked, and every press calls your handler.
|
|
1549
|
+
*/
|
|
1550
|
+
submitProgress?: boolean;
|
|
1524
1551
|
/**
|
|
1525
1552
|
* How the product strip lays its cards out. `"row"` (the default) is a
|
|
1526
1553
|
* horizontally scrolling shelf of cards. `"list"` stacks the same cards as
|
|
@@ -1558,8 +1585,13 @@ interface CoreOptions {
|
|
|
1558
1585
|
* A throw or a result that is not an array keeps the SDK's cards.
|
|
1559
1586
|
*/
|
|
1560
1587
|
mapProducts?: (products: Product[], items: MatchedItem[]) => Product[];
|
|
1561
|
-
/**
|
|
1562
|
-
|
|
1588
|
+
/**
|
|
1589
|
+
* Called when the user submits (Enter, or the submit button in Tier 1).
|
|
1590
|
+
* Until the page it opens takes over, the submit is in progress
|
|
1591
|
+
* (`isSubmitting`): return a promise to say when it is over, for a submit
|
|
1592
|
+
* that stays on the page.
|
|
1593
|
+
*/
|
|
1594
|
+
onSubmit?: (result: AutocompleteResult) => void | PromiseLike<unknown>;
|
|
1563
1595
|
/**
|
|
1564
1596
|
* Called after every successful suggestion round-trip with the structured
|
|
1565
1597
|
* query as the SDK now understands it — the same `AutocompleteResult` shape
|
|
@@ -1588,7 +1620,7 @@ interface CoreOptions {
|
|
|
1588
1620
|
* fill the input, …). Modifier / middle clicks are left to the browser so
|
|
1589
1621
|
* cmd-click and "copy link address" keep working, and don't fire this.
|
|
1590
1622
|
*/
|
|
1591
|
-
onProductSelect?: (product: Product) => void
|
|
1623
|
+
onProductSelect?: (product: Product) => void | PromiseLike<unknown>;
|
|
1592
1624
|
/**
|
|
1593
1625
|
* Adds a product to the cart from its card. When set, every card that isn't
|
|
1594
1626
|
* sold out (`available: false`) shows an add-to-cart button in the bottom
|
|
@@ -1712,6 +1744,15 @@ declare class AIAutocomplete {
|
|
|
1712
1744
|
/** Where a space-picked place left the caret, until the editor reports its own. */
|
|
1713
1745
|
private spacePickCaret;
|
|
1714
1746
|
private readonly emitSubmit;
|
|
1747
|
+
/** The submit in progress, if any: see `CoreInputState.isSubmitting`. */
|
|
1748
|
+
private readonly submitHold;
|
|
1749
|
+
/** The product selection in progress, if any: see `selectingProductId`. */
|
|
1750
|
+
private readonly productHold;
|
|
1751
|
+
/**
|
|
1752
|
+
* The keydowns the widget's own input handled. A hand-off in progress ends
|
|
1753
|
+
* when the shopper types somewhere else, and these are not somewhere else.
|
|
1754
|
+
*/
|
|
1755
|
+
private readonly ownKeys;
|
|
1715
1756
|
private readonly emitError;
|
|
1716
1757
|
constructor(container: HTMLElement, opts?: CoreOptions);
|
|
1717
1758
|
focus(): void;
|
|
@@ -1870,6 +1911,27 @@ declare class AIAutocomplete {
|
|
|
1870
1911
|
* own — a button you render — so each submit is counted once.
|
|
1871
1912
|
*/
|
|
1872
1913
|
recordSubmit(result: AutocompleteResult): void;
|
|
1914
|
+
/**
|
|
1915
|
+
* Ends whatever is in progress, a submit or a product selection, at once:
|
|
1916
|
+
* call it when the work your handler started is done and the shopper is
|
|
1917
|
+
* still on the page (a quick view opened, inline results drawn). The other
|
|
1918
|
+
* way is to return a promise from the handler.
|
|
1919
|
+
*/
|
|
1920
|
+
endSubmitProgress(): void;
|
|
1921
|
+
/** Whether Tier 1's own reset follows a submit in the same task. */
|
|
1922
|
+
private resetsAfterSubmit;
|
|
1923
|
+
/** `submitProgress`, read at call time so `update()` can flip it. */
|
|
1924
|
+
private showsProgress;
|
|
1925
|
+
/**
|
|
1926
|
+
* Marks a submit you ran yourself as in progress (`isSubmitting`), the way
|
|
1927
|
+
* the SDK marks the ones it runs (Enter, Tier 1's button): call it from a
|
|
1928
|
+
* submit button you render, right after your handler, with what the handler
|
|
1929
|
+
* returned. A promise ends it when it settles; otherwise it ends when the
|
|
1930
|
+
* input changes, when the page is shown again from the back/forward cache,
|
|
1931
|
+
* or after 8 seconds. Does nothing while a submit is already in progress,
|
|
1932
|
+
* or with `submitProgress` off.
|
|
1933
|
+
*/
|
|
1934
|
+
holdSubmit(returned?: unknown): void;
|
|
1873
1935
|
/**
|
|
1874
1936
|
* Announce a product selection. The rendered cards call this on activation;
|
|
1875
1937
|
* headless consumers rendering their own strip call it themselves.
|
|
@@ -2061,6 +2123,11 @@ declare class AIAutocomplete {
|
|
|
2061
2123
|
* only after its store write, and its own impression goes out first (the
|
|
2062
2124
|
* deferred one then matches it and is dropped).
|
|
2063
2125
|
*/
|
|
2126
|
+
/**
|
|
2127
|
+
* Ends a submit or product selection in progress once what it was started
|
|
2128
|
+
* for is no longer on screen: the input changed, or the products did.
|
|
2129
|
+
*/
|
|
2130
|
+
private subscribeHandoffHolds;
|
|
2064
2131
|
private subscribeVisibleImpression;
|
|
2065
2132
|
/**
|
|
2066
2133
|
* Records what a response put on screen: pills and their options in display
|
|
@@ -2404,6 +2471,22 @@ declare function isDimmedDay(iso: string | null, today: string, floor?: string |
|
|
|
2404
2471
|
*/
|
|
2405
2472
|
declare function dateFloorFor(formatType: FormatType | undefined, rangeStart: string | null | undefined): string | null;
|
|
2406
2473
|
|
|
2474
|
+
/**
|
|
2475
|
+
* The pills the dropdown's pill bar shows.
|
|
2476
|
+
*
|
|
2477
|
+
* While the dropdown mirrors the question just answered (`dropdownSuggestion`,
|
|
2478
|
+
* from the pick until the response's options replace the faded rows), the bar
|
|
2479
|
+
* keeps that question in front of the pills still waiting. The label then
|
|
2480
|
+
* fades out in place with its rows, and the next question arrives with its
|
|
2481
|
+
* own options in one step. Without it the bar jumps to the next cached pill
|
|
2482
|
+
* the moment loading starts: a name the response may not even lead with,
|
|
2483
|
+
* shown over rows that belong to the question before it.
|
|
2484
|
+
*
|
|
2485
|
+
* `reEditPill` is the lone pill re-edit shows (the param being re-edited), or
|
|
2486
|
+
* null outside re-edit.
|
|
2487
|
+
*/
|
|
2488
|
+
declare function dropdownPillsFor(dropdownSuggestion: Suggestion | null, reEditPill: Suggestion | null, actionableSuggestions: Suggestion[]): Suggestion[];
|
|
2489
|
+
|
|
2407
2490
|
/**
|
|
2408
2491
|
* Entrance choreography for the dropdown's option rows.
|
|
2409
2492
|
*
|
|
@@ -2895,6 +2978,8 @@ declare function syncPanelHug(dropdown: HTMLElement): void;
|
|
|
2895
2978
|
* old content stays on top as a ghost that fades to transparent with a 2px
|
|
2896
2979
|
* blur over 280ms, while the new content dissolves in (opacity 0 and a 2px
|
|
2897
2980
|
* blur to clear, 320ms after a 40ms beat) on the same soft ease.
|
|
2981
|
+
* - The new content's label arrives with the dissolve alone: its own entrance
|
|
2982
|
+
* fade is cancelled for that render (see `dropEntranceFades`).
|
|
2898
2983
|
* - While a request loads, the old content has already been fading out in
|
|
2899
2984
|
* place (`data-aia-loading`, 160ms). The ghost then starts from the opacity
|
|
2900
2985
|
* that fade had reached, never back at full, and when the fade has finished
|
|
@@ -3305,6 +3390,17 @@ interface Store<S> {
|
|
|
3305
3390
|
}
|
|
3306
3391
|
declare function createStore<S>(initial: S): Store<S>;
|
|
3307
3392
|
|
|
3393
|
+
/**
|
|
3394
|
+
* What a framework wrapper's stand-in listener answers when the integration
|
|
3395
|
+
* supplied no handler of its own. The wrappers register one listener up
|
|
3396
|
+
* front, whatever the integration passed, so the core cannot tell an unhandled
|
|
3397
|
+
* selection from a handled one by counting listeners: a hand-off nobody
|
|
3398
|
+
* handles marks nothing in progress.
|
|
3399
|
+
*
|
|
3400
|
+
* @internal for the React and Angular packages.
|
|
3401
|
+
*/
|
|
3402
|
+
declare const HANDOFF_NOT_HANDLED: unique symbol;
|
|
3403
|
+
|
|
3308
3404
|
/**
|
|
3309
3405
|
* The /suggest wire format this SDK speaks, sent as `meta.schema_version` on
|
|
3310
3406
|
* every request. The server answers in the same format.
|
|
@@ -3564,4 +3660,4 @@ declare const SMART_SUGGESTION_SPARKLE_SVG: string;
|
|
|
3564
3660
|
/** True when some pill is a question the shopper can decline. */
|
|
3565
3661
|
declare function hasSkippablePill(suggestions: Suggestion[]): boolean;
|
|
3566
3662
|
|
|
3567
|
-
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, 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, 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, previousGraphemeBoundary, productFromMatchedItem, productImageSources, productImageSrc, productInitial, productPhotoFill, productRowWheelTarget, productsFromCustomFields, queryLive, releasePanelHug, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, settlePanelMorph, shopifyImageSrc, startingHintOptions, syncPanelHug, timeWheelIndex, timeWheelIndexFromScroll, timeWheelRows, toWireIdentifiedParams, typedFragment, uiStringsFor, visibleDateRange, watchEditorHeight, withSkippedParams, withTimeWheelIndex, withoutTraditionalAutocomplete };
|
|
3663
|
+
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, previousGraphemeBoundary, productFromMatchedItem, productImageSources, productImageSrc, productInitial, productPhotoFill, productRowWheelTarget, productsFromCustomFields, queryLive, releasePanelHug, renderEditableContent, resolveFormatType, resolveIdentifiedDate, sameOptionRows, sanitizeOptionIconSvg, scrollCaretIntoView, selectedIsoFromText, selectedRangeFor, setCursorOffset, settlePanelMorph, shopifyImageSrc, startingHintOptions, syncPanelHug, timeWheelIndex, timeWheelIndexFromScroll, timeWheelRows, toWireIdentifiedParams, typedFragment, uiStringsFor, visibleDateRange, watchEditorHeight, withSkippedParams, withTimeWheelIndex, withoutTraditionalAutocomplete };
|