@magicx-eng/ai-autocomplete-vanilla 0.68.0 → 0.70.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 +1 -0
- package/REFERENCE.md +3 -2
- package/dist/index.d.mts +72 -6
- package/dist/index.d.ts +72 -6
- package/dist/index.js +14 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -630,6 +630,7 @@ For styling beyond the CSS variables, target these stable `data-aia-*` attribute
|
|
|
630
630
|
| `[data-aia-pillbar]` | Pill bar container inside the dropdown |
|
|
631
631
|
| `[data-aia-pill-scroll]` | Scrollable pill region inside the bar — carries the horizontal scroll and right-edge fade mask |
|
|
632
632
|
| `[data-aia-skip]` | The pill bar's "skip" button: at the header's trailing edge, or alone at the end of a skip-only row. Tune via `--aia-skip-font-size` / `--aia-skip-color` / `--aia-skip-color-hover` / `--aia-skip-hover-bg` |
|
|
633
|
+
| `[data-aia-hint-el]` | The empty box's hint: the lead-in and the first starting options, one at a time. Tune via `--aia-hint-color` / `--aia-hint-font-weight` / `--aia-hint-icon-opacity` |
|
|
633
634
|
| `[data-aia-option]` | Each suggestion option |
|
|
634
635
|
| `[data-aia-scroll-arrow]` | The "more below" arrow on the dropdown — carries `data-aia-visible` while shown |
|
|
635
636
|
| `[data-aia-dropdown]` | The dropdown root (listbox). Carries `data-aia-has-products` while the product strip has cards, and `data-aia-fit` while it is fitted to a short screen (see [Short screens](#short-screens)). |
|
package/REFERENCE.md
CHANGED
|
@@ -490,19 +490,20 @@ other option list (a store's branches, say), and the search never runs.
|
|
|
490
490
|
| Tapping a place already chosen | Re-opens the field focused, its answer selected |
|
|
491
491
|
| Typing in the field | Searches after a short pause (2 characters or more) |
|
|
492
492
|
| <kbd>↓</kbd> / <kbd>↑</kbd> | Moves through the places found |
|
|
493
|
+
| A space in the input right after words that exactly name the top place found (its whole name, or what its brackets hold: "sfo" for "San Francisco International Airport (SFO)") | Commits that place, as a tap would. Only once the search for those words has answered, and not while the field itself has focus |
|
|
493
494
|
| <kbd>Enter</kbd> or a tap on a place | Commits it. With nothing found, Enter commits the typed text as written. So does Enter pressed before the search answers (within the 250ms pause): nothing is highlighted yet |
|
|
494
495
|
| <kbd>Esc</kbd>, or <kbd>Backspace</kbd> in an empty field | Back to the input, the pill left open |
|
|
495
496
|
| <kbd>Tab</kbd> / <kbd>Shift</kbd>+<kbd>Tab</kbd> | On to the next control / back to the input, as for any field |
|
|
496
497
|
|
|
497
498
|
**The committed value** reads as the place and its region (`Seattle, WA`), with
|
|
498
499
|
the server's lead-in before it when there is one (`in Seattle, WA`). A picked
|
|
499
|
-
place also records the provider's place ID on the parameter's `metadata` under
|
|
500
|
+
place also records the provider's place ID and the place's name on the parameter's `metadata` under
|
|
500
501
|
`LOCATION_META_KEY` (`aiaPlace`); typed text records none:
|
|
501
502
|
|
|
502
503
|
```ts
|
|
503
504
|
import { LOCATION_META_KEY } from "@magicx-eng/ai-autocomplete-vanilla";
|
|
504
505
|
|
|
505
|
-
const place = param.metadata?.[LOCATION_META_KEY]; // { id: "ChIJ…" } | undefined
|
|
506
|
+
const place = param.metadata?.[LOCATION_META_KEY]; // { id: "ChIJ…", name: "Seattle" } | undefined
|
|
506
507
|
```
|
|
507
508
|
|
|
508
509
|
**Re-editing** a committed place re-opens the field on it, selected, so typing
|
package/dist/index.d.mts
CHANGED
|
@@ -774,7 +774,7 @@ declare function resolveFormatType(source: {
|
|
|
774
774
|
|
|
775
775
|
/**
|
|
776
776
|
* Metadata key that carries the provider's place ID on an answer picked from
|
|
777
|
-
* the location search, as `{ id }`. A typed answer (Enter with no result
|
|
777
|
+
* the location search, as `{ id, name }`. A typed answer (Enter with no result
|
|
778
778
|
* highlighted) carries none: it names no place the provider knows.
|
|
779
779
|
*/
|
|
780
780
|
declare const LOCATION_META_KEY = "aiaPlace";
|
|
@@ -1618,6 +1618,8 @@ declare class AIAutocomplete {
|
|
|
1618
1618
|
private locationAbort;
|
|
1619
1619
|
/** One provider session per location pill: every search for it, then the pick. */
|
|
1620
1620
|
private locationSession;
|
|
1621
|
+
/** Where a space-picked place left the caret, until the editor reports its own. */
|
|
1622
|
+
private spacePickCaret;
|
|
1621
1623
|
private readonly emitSubmit;
|
|
1622
1624
|
private readonly emitError;
|
|
1623
1625
|
constructor(container: HTMLElement, opts?: CoreOptions);
|
|
@@ -1828,6 +1830,18 @@ declare class AIAutocomplete {
|
|
|
1828
1830
|
* `selectOption` like a tapped option — see `buildLocationOption`.
|
|
1829
1831
|
*/
|
|
1830
1832
|
commitLocation(index?: number): void;
|
|
1833
|
+
/**
|
|
1834
|
+
* A space typed in the input right after words that name the top location
|
|
1835
|
+
* result exactly (its name, or what its brackets hold) picks that place,
|
|
1836
|
+
* as tapping its row would. Only once the search for those words has
|
|
1837
|
+
* answered, so a space while it loads keeps typing, and only while the field
|
|
1838
|
+
* is on screen, so a space never commits a place the user cannot see. The
|
|
1839
|
+
* exact match outranks the field's highlight: it is the top place the typed
|
|
1840
|
+
* words name, whichever row the arrows last rested on.
|
|
1841
|
+
*/
|
|
1842
|
+
private spacePicksTopPlace;
|
|
1843
|
+
/** The place query the words after the last chip make, as the field mirrors it. */
|
|
1844
|
+
private typedLocationQuery;
|
|
1831
1845
|
private runLocationSearch;
|
|
1832
1846
|
private cancelLocationSearch;
|
|
1833
1847
|
/**
|
|
@@ -2050,6 +2064,8 @@ interface LooseDateOptions {
|
|
|
2050
2064
|
* Handles, in order: ISO; a month name with a day either side of it, with or
|
|
2051
2065
|
* without an ordinal suffix or a year; and a numeric pair where only one
|
|
2052
2066
|
* reading is possible (`13/05` can only be day-first, since 13 is not a month).
|
|
2067
|
+
* A day written alone with its ordinal suffix ("the 1st") resolves to the next
|
|
2068
|
+
* date on or after today that falls on that day.
|
|
2053
2069
|
*
|
|
2054
2070
|
* Deliberately NOT handled:
|
|
2055
2071
|
* - A numeric pair where both numbers are 12 or under. `09/05` is September
|
|
@@ -2109,9 +2125,10 @@ declare const DATE_RANGE_META_END = "aiaDateRangeEnd";
|
|
|
2109
2125
|
* - A backwards span ("October 13 - September 11"). Nothing here can tell a
|
|
2110
2126
|
* typo from a year boundary the writer left implicit, and silently swapping
|
|
2111
2127
|
* the ends would answer a question the user didn't ask.
|
|
2112
|
-
* - A shared-month shorthand ("September 11 - 13"). The
|
|
2113
|
-
*
|
|
2114
|
-
*
|
|
2128
|
+
* - A shared-month shorthand with a bare number ("September 11 - 13"). The
|
|
2129
|
+
* right half alone is not a date: a bare number is as likely a count.
|
|
2130
|
+
* With its ordinal suffix ("September 11 - 13th") the right half is a day
|
|
2131
|
+
* and resolves to its next date on or after the start, September 13.
|
|
2115
2132
|
* - Anything where two different splits both read as a range — the text is
|
|
2116
2133
|
* then genuinely ambiguous about where its own separator is.
|
|
2117
2134
|
*
|
|
@@ -2710,6 +2727,10 @@ declare function syncPanelHug(dropdown: HTMLElement): void;
|
|
|
2710
2727
|
* old content stays on top as a ghost that fades to transparent with a 2px
|
|
2711
2728
|
* blur over 280ms, while the new content dissolves in (opacity 0 and a 2px
|
|
2712
2729
|
* blur to clear, 320ms after a 40ms beat) on the same soft ease.
|
|
2730
|
+
* - While a request loads, the old content has already been fading out in
|
|
2731
|
+
* place (`data-aia-loading`, 160ms). The ghost then starts from the opacity
|
|
2732
|
+
* that fade had reached, never back at full, and when the fade has finished
|
|
2733
|
+
* there is no ghost at all: the new content just dissolves in.
|
|
2713
2734
|
*
|
|
2714
2735
|
* Opening and closing are CSS (the `--visible` transition). This module only
|
|
2715
2736
|
* runs between two open renders. All three packages call `settlePanelMorph`
|
|
@@ -2792,6 +2813,45 @@ declare const PLACEHOLDER_SWAP_GAP_MS = 50;
|
|
|
2792
2813
|
/** Set on the input while the outgoing phrase fades; the stylesheets fade `::before` on it. */
|
|
2793
2814
|
declare const PLACEHOLDER_LEAVING_ATTR = "data-aia-placeholder-leaving";
|
|
2794
2815
|
|
|
2816
|
+
/**
|
|
2817
|
+
* The empty box's hint (Brad 2026-11-18): the placeholder's lead-in ("Find")
|
|
2818
|
+
* followed by the first three starting options, one at a time ("Find a table"
|
|
2819
|
+
* → "Find a date spot" → "Find trending restaurants"). The option's noun
|
|
2820
|
+
* carries its icon. The change is a word swap: words both lines share stay
|
|
2821
|
+
* where they are (sliding if they must move); only the words that change
|
|
2822
|
+
* dissolve, blur(2px) + fade, 280 ms out and 320 ms in.
|
|
2823
|
+
*
|
|
2824
|
+
* The hint is a non-editable sibling laid over the input, never a child of
|
|
2825
|
+
* the contentEditable, so the editable's DOM and the core's notion of the
|
|
2826
|
+
* placeholder (Tab-to-accept, prefix-typing suppression) are unchanged. While
|
|
2827
|
+
* it shows, `data-aia-hint` on the input hides the `::before` placeholder.
|
|
2828
|
+
*/
|
|
2829
|
+
interface StartingHintOption {
|
|
2830
|
+
text: string;
|
|
2831
|
+
icon_svg?: string;
|
|
2832
|
+
}
|
|
2833
|
+
/** How long each option holds before the next swaps in. */
|
|
2834
|
+
declare const HINT_HOLD_MS = 2600;
|
|
2835
|
+
declare const HINT_ATTR = "data-aia-hint";
|
|
2836
|
+
/** Marks the hint element itself, so stylesheets (React's CSS modules
|
|
2837
|
+
* included) can reach it without a class name. */
|
|
2838
|
+
declare const HINT_EL_ATTR = "data-aia-hint-el";
|
|
2839
|
+
/** Test / teardown hook: remove the hint and its timer for this input. */
|
|
2840
|
+
declare function cancelStartingHint(input: HTMLElement): void;
|
|
2841
|
+
/**
|
|
2842
|
+
* The hint's options from the actionable suggestions: the first question's
|
|
2843
|
+
* tappable options (a traditional-autocomplete answer is not a question).
|
|
2844
|
+
*/
|
|
2845
|
+
declare function startingHintOptions(suggestions: readonly {
|
|
2846
|
+
parameter: string;
|
|
2847
|
+
type?: {
|
|
2848
|
+
kind?: string;
|
|
2849
|
+
};
|
|
2850
|
+
options?: readonly (StartingHintOption & {
|
|
2851
|
+
is_tappable?: boolean;
|
|
2852
|
+
})[];
|
|
2853
|
+
}[]): StartingHintOption[];
|
|
2854
|
+
|
|
2795
2855
|
interface RenderEditableArgs {
|
|
2796
2856
|
input: HTMLElement;
|
|
2797
2857
|
segments: Segment[];
|
|
@@ -2810,6 +2870,12 @@ interface RenderEditableArgs {
|
|
|
2810
2870
|
showChipIcons?: boolean;
|
|
2811
2871
|
/** Whether completed chips draw the picture of the option that answered them, in place of the icon. Default: true. */
|
|
2812
2872
|
showChipImages?: boolean;
|
|
2873
|
+
/**
|
|
2874
|
+
* The starting question's options. While the box is empty and there are at
|
|
2875
|
+
* least two, the placeholder's lead word cycles through the first three of
|
|
2876
|
+
* them (see startingHint.ts). Omitted or empty: the plain placeholder.
|
|
2877
|
+
*/
|
|
2878
|
+
hintOptions?: readonly StartingHintOption[];
|
|
2813
2879
|
}
|
|
2814
2880
|
/**
|
|
2815
2881
|
* Renders text segments into the contentEditable input. Completed params are
|
|
@@ -3108,7 +3174,7 @@ declare function buildQuery(text: string, completedParams: CompletedParamState[]
|
|
|
3108
3174
|
/**
|
|
3109
3175
|
* The dropdown footer's keyboard hint has three states, in priority order:
|
|
3110
3176
|
* 1. an option is highlighted → "enter to proceed" (Enter commits it);
|
|
3111
|
-
* 2. otherwise, the input is empty → "tab to select" (Tab
|
|
3177
|
+
* 2. otherwise, the input is empty → "tab to select" (Tab picks the first
|
|
3112
3178
|
* option). This is the ONLY state that shows "tab to select";
|
|
3113
3179
|
* 3. otherwise (the input has text) → "→ to skip" — the right arrow skips the
|
|
3114
3180
|
* active pill.
|
|
@@ -3308,4 +3374,4 @@ declare const SMART_SUGGESTION_SPARKLE_SVG: string;
|
|
|
3308
3374
|
/** True when some pill is a question the shopper can decline. */
|
|
3309
3375
|
declare function hasSkippablePill(suggestions: Suggestion[]): boolean;
|
|
3310
3376
|
|
|
3311
|
-
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, 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 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, attachProductRowWheel, attachScrollArrow, attachViewportFit, buildAttributionUrl, buildDateOptions, buildLocationOption, buildQuery, buildSubmitResult, buildTimeOption, cellDay, cellIso, chipIdFromTap, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateFloorFor, dateSelectionFor, destroyPanelMorph, 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, syncPanelHug, timeWheelIndex, timeWheelIndexFromScroll, timeWheelRows, toWireIdentifiedParams, typedFragment, uiStringsFor, visibleDateRange, watchEditorHeight, withSkippedParams, withTimeWheelIndex, withoutTraditionalAutocomplete };
|
|
3377
|
+
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, attachProductRowWheel, attachScrollArrow, attachViewportFit, buildAttributionUrl, buildDateOptions, buildLocationOption, buildQuery, buildSubmitResult, buildTimeOption, cancelStartingHint, cellDay, cellIso, chipIdFromTap, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateFloorFor, dateSelectionFor, destroyPanelMorph, 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
|
@@ -774,7 +774,7 @@ declare function resolveFormatType(source: {
|
|
|
774
774
|
|
|
775
775
|
/**
|
|
776
776
|
* Metadata key that carries the provider's place ID on an answer picked from
|
|
777
|
-
* the location search, as `{ id }`. A typed answer (Enter with no result
|
|
777
|
+
* the location search, as `{ id, name }`. A typed answer (Enter with no result
|
|
778
778
|
* highlighted) carries none: it names no place the provider knows.
|
|
779
779
|
*/
|
|
780
780
|
declare const LOCATION_META_KEY = "aiaPlace";
|
|
@@ -1618,6 +1618,8 @@ declare class AIAutocomplete {
|
|
|
1618
1618
|
private locationAbort;
|
|
1619
1619
|
/** One provider session per location pill: every search for it, then the pick. */
|
|
1620
1620
|
private locationSession;
|
|
1621
|
+
/** Where a space-picked place left the caret, until the editor reports its own. */
|
|
1622
|
+
private spacePickCaret;
|
|
1621
1623
|
private readonly emitSubmit;
|
|
1622
1624
|
private readonly emitError;
|
|
1623
1625
|
constructor(container: HTMLElement, opts?: CoreOptions);
|
|
@@ -1828,6 +1830,18 @@ declare class AIAutocomplete {
|
|
|
1828
1830
|
* `selectOption` like a tapped option — see `buildLocationOption`.
|
|
1829
1831
|
*/
|
|
1830
1832
|
commitLocation(index?: number): void;
|
|
1833
|
+
/**
|
|
1834
|
+
* A space typed in the input right after words that name the top location
|
|
1835
|
+
* result exactly (its name, or what its brackets hold) picks that place,
|
|
1836
|
+
* as tapping its row would. Only once the search for those words has
|
|
1837
|
+
* answered, so a space while it loads keeps typing, and only while the field
|
|
1838
|
+
* is on screen, so a space never commits a place the user cannot see. The
|
|
1839
|
+
* exact match outranks the field's highlight: it is the top place the typed
|
|
1840
|
+
* words name, whichever row the arrows last rested on.
|
|
1841
|
+
*/
|
|
1842
|
+
private spacePicksTopPlace;
|
|
1843
|
+
/** The place query the words after the last chip make, as the field mirrors it. */
|
|
1844
|
+
private typedLocationQuery;
|
|
1831
1845
|
private runLocationSearch;
|
|
1832
1846
|
private cancelLocationSearch;
|
|
1833
1847
|
/**
|
|
@@ -2050,6 +2064,8 @@ interface LooseDateOptions {
|
|
|
2050
2064
|
* Handles, in order: ISO; a month name with a day either side of it, with or
|
|
2051
2065
|
* without an ordinal suffix or a year; and a numeric pair where only one
|
|
2052
2066
|
* reading is possible (`13/05` can only be day-first, since 13 is not a month).
|
|
2067
|
+
* A day written alone with its ordinal suffix ("the 1st") resolves to the next
|
|
2068
|
+
* date on or after today that falls on that day.
|
|
2053
2069
|
*
|
|
2054
2070
|
* Deliberately NOT handled:
|
|
2055
2071
|
* - A numeric pair where both numbers are 12 or under. `09/05` is September
|
|
@@ -2109,9 +2125,10 @@ declare const DATE_RANGE_META_END = "aiaDateRangeEnd";
|
|
|
2109
2125
|
* - A backwards span ("October 13 - September 11"). Nothing here can tell a
|
|
2110
2126
|
* typo from a year boundary the writer left implicit, and silently swapping
|
|
2111
2127
|
* the ends would answer a question the user didn't ask.
|
|
2112
|
-
* - A shared-month shorthand ("September 11 - 13"). The
|
|
2113
|
-
*
|
|
2114
|
-
*
|
|
2128
|
+
* - A shared-month shorthand with a bare number ("September 11 - 13"). The
|
|
2129
|
+
* right half alone is not a date: a bare number is as likely a count.
|
|
2130
|
+
* With its ordinal suffix ("September 11 - 13th") the right half is a day
|
|
2131
|
+
* and resolves to its next date on or after the start, September 13.
|
|
2115
2132
|
* - Anything where two different splits both read as a range — the text is
|
|
2116
2133
|
* then genuinely ambiguous about where its own separator is.
|
|
2117
2134
|
*
|
|
@@ -2710,6 +2727,10 @@ declare function syncPanelHug(dropdown: HTMLElement): void;
|
|
|
2710
2727
|
* old content stays on top as a ghost that fades to transparent with a 2px
|
|
2711
2728
|
* blur over 280ms, while the new content dissolves in (opacity 0 and a 2px
|
|
2712
2729
|
* blur to clear, 320ms after a 40ms beat) on the same soft ease.
|
|
2730
|
+
* - While a request loads, the old content has already been fading out in
|
|
2731
|
+
* place (`data-aia-loading`, 160ms). The ghost then starts from the opacity
|
|
2732
|
+
* that fade had reached, never back at full, and when the fade has finished
|
|
2733
|
+
* there is no ghost at all: the new content just dissolves in.
|
|
2713
2734
|
*
|
|
2714
2735
|
* Opening and closing are CSS (the `--visible` transition). This module only
|
|
2715
2736
|
* runs between two open renders. All three packages call `settlePanelMorph`
|
|
@@ -2792,6 +2813,45 @@ declare const PLACEHOLDER_SWAP_GAP_MS = 50;
|
|
|
2792
2813
|
/** Set on the input while the outgoing phrase fades; the stylesheets fade `::before` on it. */
|
|
2793
2814
|
declare const PLACEHOLDER_LEAVING_ATTR = "data-aia-placeholder-leaving";
|
|
2794
2815
|
|
|
2816
|
+
/**
|
|
2817
|
+
* The empty box's hint (Brad 2026-11-18): the placeholder's lead-in ("Find")
|
|
2818
|
+
* followed by the first three starting options, one at a time ("Find a table"
|
|
2819
|
+
* → "Find a date spot" → "Find trending restaurants"). The option's noun
|
|
2820
|
+
* carries its icon. The change is a word swap: words both lines share stay
|
|
2821
|
+
* where they are (sliding if they must move); only the words that change
|
|
2822
|
+
* dissolve, blur(2px) + fade, 280 ms out and 320 ms in.
|
|
2823
|
+
*
|
|
2824
|
+
* The hint is a non-editable sibling laid over the input, never a child of
|
|
2825
|
+
* the contentEditable, so the editable's DOM and the core's notion of the
|
|
2826
|
+
* placeholder (Tab-to-accept, prefix-typing suppression) are unchanged. While
|
|
2827
|
+
* it shows, `data-aia-hint` on the input hides the `::before` placeholder.
|
|
2828
|
+
*/
|
|
2829
|
+
interface StartingHintOption {
|
|
2830
|
+
text: string;
|
|
2831
|
+
icon_svg?: string;
|
|
2832
|
+
}
|
|
2833
|
+
/** How long each option holds before the next swaps in. */
|
|
2834
|
+
declare const HINT_HOLD_MS = 2600;
|
|
2835
|
+
declare const HINT_ATTR = "data-aia-hint";
|
|
2836
|
+
/** Marks the hint element itself, so stylesheets (React's CSS modules
|
|
2837
|
+
* included) can reach it without a class name. */
|
|
2838
|
+
declare const HINT_EL_ATTR = "data-aia-hint-el";
|
|
2839
|
+
/** Test / teardown hook: remove the hint and its timer for this input. */
|
|
2840
|
+
declare function cancelStartingHint(input: HTMLElement): void;
|
|
2841
|
+
/**
|
|
2842
|
+
* The hint's options from the actionable suggestions: the first question's
|
|
2843
|
+
* tappable options (a traditional-autocomplete answer is not a question).
|
|
2844
|
+
*/
|
|
2845
|
+
declare function startingHintOptions(suggestions: readonly {
|
|
2846
|
+
parameter: string;
|
|
2847
|
+
type?: {
|
|
2848
|
+
kind?: string;
|
|
2849
|
+
};
|
|
2850
|
+
options?: readonly (StartingHintOption & {
|
|
2851
|
+
is_tappable?: boolean;
|
|
2852
|
+
})[];
|
|
2853
|
+
}[]): StartingHintOption[];
|
|
2854
|
+
|
|
2795
2855
|
interface RenderEditableArgs {
|
|
2796
2856
|
input: HTMLElement;
|
|
2797
2857
|
segments: Segment[];
|
|
@@ -2810,6 +2870,12 @@ interface RenderEditableArgs {
|
|
|
2810
2870
|
showChipIcons?: boolean;
|
|
2811
2871
|
/** Whether completed chips draw the picture of the option that answered them, in place of the icon. Default: true. */
|
|
2812
2872
|
showChipImages?: boolean;
|
|
2873
|
+
/**
|
|
2874
|
+
* The starting question's options. While the box is empty and there are at
|
|
2875
|
+
* least two, the placeholder's lead word cycles through the first three of
|
|
2876
|
+
* them (see startingHint.ts). Omitted or empty: the plain placeholder.
|
|
2877
|
+
*/
|
|
2878
|
+
hintOptions?: readonly StartingHintOption[];
|
|
2813
2879
|
}
|
|
2814
2880
|
/**
|
|
2815
2881
|
* Renders text segments into the contentEditable input. Completed params are
|
|
@@ -3108,7 +3174,7 @@ declare function buildQuery(text: string, completedParams: CompletedParamState[]
|
|
|
3108
3174
|
/**
|
|
3109
3175
|
* The dropdown footer's keyboard hint has three states, in priority order:
|
|
3110
3176
|
* 1. an option is highlighted → "enter to proceed" (Enter commits it);
|
|
3111
|
-
* 2. otherwise, the input is empty → "tab to select" (Tab
|
|
3177
|
+
* 2. otherwise, the input is empty → "tab to select" (Tab picks the first
|
|
3112
3178
|
* option). This is the ONLY state that shows "tab to select";
|
|
3113
3179
|
* 3. otherwise (the input has text) → "→ to skip" — the right arrow skips the
|
|
3114
3180
|
* active pill.
|
|
@@ -3308,4 +3374,4 @@ declare const SMART_SUGGESTION_SPARKLE_SVG: string;
|
|
|
3308
3374
|
/** True when some pill is a question the shopper can decline. */
|
|
3309
3375
|
declare function hasSkippablePill(suggestions: Suggestion[]): boolean;
|
|
3310
3376
|
|
|
3311
|
-
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, 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 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, attachProductRowWheel, attachScrollArrow, attachViewportFit, buildAttributionUrl, buildDateOptions, buildLocationOption, buildQuery, buildSubmitResult, buildTimeOption, cellDay, cellIso, chipIdFromTap, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateFloorFor, dateSelectionFor, destroyPanelMorph, 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, syncPanelHug, timeWheelIndex, timeWheelIndexFromScroll, timeWheelRows, toWireIdentifiedParams, typedFragment, uiStringsFor, visibleDateRange, watchEditorHeight, withSkippedParams, withTimeWheelIndex, withoutTraditionalAutocomplete };
|
|
3377
|
+
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, attachProductRowWheel, attachScrollArrow, attachViewportFit, buildAttributionUrl, buildDateOptions, buildLocationOption, buildQuery, buildSubmitResult, buildTimeOption, cancelStartingHint, cellDay, cellIso, chipIdFromTap, computeOptionsGridLayout, containScroll, createStore, cursorIsAtEnd, dateCellMarks, dateFloorFor, dateSelectionFor, destroyPanelMorph, 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 };
|