@magicx-eng/ai-autocomplete-vanilla 0.71.0 → 0.72.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 CHANGED
@@ -115,6 +115,7 @@ const ac = new AIAutocomplete(container, {
115
115
  showOptionIcons: true, // false = render option rows as text only (no icons)
116
116
  showChipIcons: true, // false = render completed chips as text only (no icons)
117
117
  showChipImages: true, // false = never draw an option's picture on its completed chip
118
+ showChipRemove: false, // true = each completed chip ends in a small faint × that removes it in one tap
118
119
  showOptionImages: true, // false = never draw an option's image_url thumbnail
119
120
  showOptionCounts: true, // false = never show an option's item_count
120
121
 
@@ -350,6 +351,8 @@ unsub();
350
351
 
351
352
  > **Option pictures and counts.** An option may also carry `image_url` — a picture of the best-matching catalog item offering it — and `item_count`, how many items offer it (each is present only when the server includes it; when it includes counts, the options also arrive ordered by them, most items first; a starting state carries pictures but no counts). The built-in dropdown draws the picture as a square thumbnail before the option's text (in place of its `icon_svg`, so a row never leads with two visuals) and the count as a muted label at the row's trailing edge (`"12 items"`). Icons and pictures are all-or-nothing per list: if any tappable option would draw neither, no row draws one, so a list never mixes rows with and without a leading visual (non-tappable rows don't count). A custom dropdown can apply the same rule with the exported `optionsShowLeadingVisuals(options, showIcons, showImages)`. The unit word after the number is a token: set `--aia-option-count-unit: "sneakers"` to name what is being counted, `--aia-option-count-unit-one: "sneaker"` for a count of 1 (it falls back to the plural token), or `--aia-option-count-unit: ""` for the number alone. When rendering options yourself, pass `image_url` through the exported `optionImageSrc` before using it as an `<img src>` — it returns the URL only when it is `http(s)` and `null` otherwise — and `formatOptionCount(option.item_count)` gives the number the built-in rows print (`null` when there is no count); `optionCountLabel(count, unit?)` appends a unit for a dropdown that prints the word itself (`"item"` / `"items"` by default; one word, a `{ one, other }` pair, or `""` for none). Both surfaces can be switched off: `showOptionImages: false` renders rows without pictures (an option's icon then draws instead) and `showOptionCounts: false` hides the counts. A picked option's `image_url` is copied onto its completed parameter too, and the chip in the input draws it as a small rounded tile before its text, in place of the icon; `showChipImages: false` renders chips without pictures (the icon then draws instead). The tile is sized by `--aia-option-image-size` (28px), rounded by `--aia-option-image-radius` (8.4px), spaced by `--aia-option-image-gap` (8.4px) and filled by `--aia-option-image-bg` (default: `--aia-skeleton-bg`) as a placeholder until its picture loads (or if the picture fails); a loaded picture is scaled to fit rather than cropped and sits on the dropdown's background, and one narrower than the tile is rounded on its own corners by `--aia-option-picture-radius` (4.2px); in a grid with pictures, an icon row draws its glyph at `--aia-option-tile-icon-size` (1.5em) so it holds the picture column; the count reads `--aia-option-count-font-size` (8.4px), `--aia-option-count-color` and `--aia-option-count-opacity` (0.6); the chip's tile reads `--aia-chip-image-size` (1.25em of the chip's font), `--aia-chip-image-radius` (4px) and `--aia-chip-image-bg` (default: `--aia-skeleton-bg`), the placeholder fill shown until the picture loads; a loaded picture narrower than the tile narrows it to the picture's own width, so the radius rounds the picture.
352
353
 
354
+ > **Removing a chip.** With `showChipRemove: true`, every completed chip in the input ends in a small, faint "×"; one tap or click on it removes that chip, the same result as Backspace at the chip's trailing edge (`removeParam(id)` does the same from code). Only completed chips get one; values the server merely identified in typed text do not. The × reads `--aia-chip-remove-opacity` (0.32) and `--aia-chip-remove-opacity-hover` (0.7).
355
+
353
356
  > **Parameter names under options.** An option that completes the word being typed (the server's `traditional_autocomplete` suggestion) can read the same as an option of another parameter, so the built-in dropdown draws the name of the parameter it answers under its text, muted and smaller (`Flavor`, `Subcategory`); the SDK sets it as `parameterLabel` from the option's `parameter`. It reads `--aia-option-parameter-font-size` (8.4px), `--aia-option-parameter-color` and `--aia-option-parameter-opacity` (0.6).
354
357
 
355
358
  ### State shape (`CoreState`)
@@ -394,6 +397,7 @@ unsub();
394
397
  | `setActivePill(index)` | Reorder pills — moves pill at `index` to front (active). |
395
398
  | `skipActivePill()` | Skip the active pill — same action as → / the dropdown's skip button. Records it in `skippedParams`; no-ops during re-edit and the post-selection window. Use it to drive a custom skip affordance (e.g. with `showSkipButton: false`). |
396
399
  | `removeLastParam()` | Remove the last completed param from state. The text stays in the input as plain text. |
400
+ | `removeParam(paramId)` | Remove the completed chip with that id, the same result as Backspace at the chip's trailing edge; the chip's × (`showChipRemove`) calls it. Any value's id of one multi-select answer removes its joined chip. Returns `false`, changing nothing, when no completed chip has that id. |
397
401
  | `clearNewParamId()` | Clear shimmer animation state. |
398
402
  | `reset()` | Clear all state, re-fetch initial suggestions, and start a new session (rotates `session_id`). Call this after handling submit. |
399
403
  | `prepareSubmit()` | Call before building a submit result from your own button. A typed word that equals exactly one completion candidate becomes a completed param, the same as Enter. A typed value the response returned with no pill yet (`state: "need_confirmation"`) joins `identifiedParams` if the text has not changed since that response. A submit that skips this call leaves that value out. Read the updated state with `getState()` to build the result. |
package/REFERENCE.md CHANGED
@@ -594,7 +594,7 @@ The full input also accepts `--aia-input-radius` and `--aia-written-text-font-we
594
594
  | `--aia-date-today-ring` | `--aia-option-color` | `--aia-option-color` | Outline drawn around today's date. |
595
595
  | `--aia-date-selected-bg` | white at 12% | white at 12% | Fill behind the date a re-edited parameter already holds. |
596
596
  | `--aia-date-range-bg` | white at 6% | white at 6% | Band across the days between the two ends of a picked date range. The ends themselves use `--aia-date-selected-bg`. |
597
- | `--aia-date-reference-bg` | white at 7% | white at 7% | Soft fill behind a day another answer already holds (the pickup date while the return date is asked), shown for reference; the day stays pickable. |
597
+ | `--aia-date-reference-bg` | the day's text colour at 14% | the day's text colour at 14% | Fill behind a day another answer already holds (the pickup date while the return date is asked), shown for reference with the number in the selected text colour and a heavier weight; the day stays pickable. |
598
598
  | `--aia-time-panel-width` | `240px` | `240px` | Max width of the whole dropdown panel while the time wheel is up. |
599
599
  | `--aia-time-font-size` | `15px` | `15px` | The time wheel's numbers and its `:` separator. |
600
600
  | `--aia-time-band-bg` | white at 8% | white at 8% | The band behind the wheels' top rows — the chosen time. |
@@ -615,3 +615,5 @@ The full input also accepts `--aia-input-radius` and `--aia-written-text-font-we
615
615
  | `--aia-location-font-size` | `15px` | `15px` | The location field's text and the place names. |
616
616
  | `--aia-location-row-bg-highlighted` | `--aia-streak-rgb` at 8% (indigo) | `--aia-streak-rgb` at 8% (white) | The highlighted (or hovered) place. |
617
617
  | `--aia-skeleton-bg` | `rgba(189, 189, 189, 0.083)` | `#1a1b1d` | Fill color of the option and chip image tiles while their picture loads (unless `--aia-option-image-bg` / `--aia-chip-image-bg` are set). |
618
+ | `--aia-chip-remove-opacity` | `0.32` | `0.32` | Opacity of a completed chip's remove × (`showChipRemove`). The × is for a mouse or a tap and is hidden from assistive technology; from the keyboard, Backspace at the end of a chip removes it. |
619
+ | `--aia-chip-remove-opacity-hover` | `0.7` | `0.7` | Opacity of that × under a hovering pointer (never on touch). |
package/dist/index.d.mts CHANGED
@@ -1374,6 +1374,12 @@ interface CoreOptions {
1374
1374
  showChipIcons?: boolean;
1375
1375
  /** When true (default), a completed chip in the input draws the picture (`image_url`) of the option that answered it, in place of its icon. Set to false to render chips without pictures. */
1376
1376
  showChipImages?: boolean;
1377
+ /**
1378
+ * When true, every completed chip in the input ends in a small, faint "×"
1379
+ * that removes the chip in one tap (the same result as Backspace at the
1380
+ * chip's trailing edge). Default: false.
1381
+ */
1382
+ showChipRemove?: boolean;
1377
1383
  /** When true (default), an option that carries an `image_url` draws it as a square thumbnail before its text in the dropdown (in place of its `icon_svg`). Set to false to render option rows without pictures. */
1378
1384
  showOptionImages?: boolean;
1379
1385
  /** When true (default), an option that carries an `item_count` shows it as a muted label at the row's trailing edge ("12 items"). Set to false to hide the counts. */
@@ -1693,6 +1699,22 @@ declare class AIAutocomplete {
1693
1699
  * Returns true when a param was reconciled (caller should `preventDefault`).
1694
1700
  */
1695
1701
  removeParamAtCaret(offset: number): boolean;
1702
+ /**
1703
+ * Take a whole chip out of the text: its span, the space seam it leaves
1704
+ * (so the surrounding words don't end up double-spaced), and its param.
1705
+ * Shared by Backspace at a chip's trailing edge and the chip's "×".
1706
+ */
1707
+ private removeWholeChip;
1708
+ /**
1709
+ * Remove a completed chip by id — the chip's "×" (`showChipRemove`). Same
1710
+ * result as Backspace at the chip's trailing edge: the chip's text and the
1711
+ * space seam it leaves come out, and any re-edit open closes first. The
1712
+ * caret follows only when the editor has focus, so a "×" pressed on an
1713
+ * unfocused editor does not pull focus into it.
1714
+ * Any value of one multi_select answer names its joined chip. Returns true
1715
+ * when a chip was removed; false (and nothing changes) when none has that id.
1716
+ */
1717
+ removeParam(paramId: string): boolean;
1696
1718
  /**
1697
1719
  * ArrowLeft while the caret sits at a completed pill's trailing edge selects
1698
1720
  * the pill rather than moving the caret into it: re-edit turns on, the pill
@@ -1860,6 +1882,13 @@ declare class AIAutocomplete {
1860
1882
  private isReEditing;
1861
1883
  /** The words typed for the place: after the last chip and any span recognized as another parameter. */
1862
1884
  private typedLocationPhrase;
1885
+ /**
1886
+ * The segments, counting the spans the server recognized that are not
1887
+ * chips yet: with `commitOnWordEnd` a recognized word waits for its space,
1888
+ * and it is another question's answer from the moment it is recognized
1889
+ * ("paris" in "flight to paris" is the destination, not where to leave from).
1890
+ */
1891
+ private segmentsWithPending;
1863
1892
  private runLocationSearch;
1864
1893
  private cancelLocationSearch;
1865
1894
  /**
@@ -2439,6 +2468,28 @@ declare function sameOptionRows(measured: readonly {
2439
2468
  text: string;
2440
2469
  }[]): boolean;
2441
2470
 
2471
+ /**
2472
+ * Wires the chips' remove "×" (`showChipRemove`) on an editor: one set of
2473
+ * delegated listeners on the editable, shared by the vanilla, React and
2474
+ * Angular editors, so the "×" elements carry no listener of their own. Attach
2475
+ * it only while the option is on.
2476
+ *
2477
+ * A mouse removes the chip on `pointerdown`. A finger or pen removes it on
2478
+ * `pointerup`, and only when it lifts on the same "×" within
2479
+ * `CHIP_REMOVE_TAP_SLOP` of where it landed, so a touch that drifts off or is
2480
+ * cancelled removes nothing.
2481
+ *
2482
+ * The press is cancelled so it neither moves the caret into the chip (which
2483
+ * would re-open it) nor takes focus; on iOS that takes the `touchstart` too.
2484
+ * Removing the chip re-renders the editor, so the rest of the same press
2485
+ * (`mousedown`, `click`) lands on whatever now sits under the pointer; those
2486
+ * are cancelled as well. Only that press: its `click`, or the next
2487
+ * `pointerdown`, ends it.
2488
+ *
2489
+ * Returns a cleanup that removes the listeners.
2490
+ */
2491
+ declare function attachChipRemove(editable: HTMLElement, removeParam: (paramId: string) => void): () => void;
2492
+
2442
2493
  /**
2443
2494
  * Plain-text caret utilities for contentEditable elements.
2444
2495
  *
@@ -2905,6 +2956,8 @@ interface RenderEditableArgs {
2905
2956
  * them (see startingHint.ts). Omitted or empty: the plain placeholder.
2906
2957
  */
2907
2958
  hintOptions?: readonly StartingHintOption[];
2959
+ /** Whether completed chips end in a faint "×" that removes them. Default: false. */
2960
+ showChipRemove?: boolean;
2908
2961
  }
2909
2962
  /**
2910
2963
  * Renders text segments into the contentEditable input. Completed params are
@@ -3403,4 +3456,4 @@ declare const SMART_SUGGESTION_SPARKLE_SVG: string;
3403
3456
  /** True when some pill is a question the shopper can decline. */
3404
3457
  declare function hasSkippablePill(suggestions: Suggestion[]): boolean;
3405
3458
 
3406
- 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 };
3459
+ 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, 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
@@ -1374,6 +1374,12 @@ interface CoreOptions {
1374
1374
  showChipIcons?: boolean;
1375
1375
  /** When true (default), a completed chip in the input draws the picture (`image_url`) of the option that answered it, in place of its icon. Set to false to render chips without pictures. */
1376
1376
  showChipImages?: boolean;
1377
+ /**
1378
+ * When true, every completed chip in the input ends in a small, faint "×"
1379
+ * that removes the chip in one tap (the same result as Backspace at the
1380
+ * chip's trailing edge). Default: false.
1381
+ */
1382
+ showChipRemove?: boolean;
1377
1383
  /** When true (default), an option that carries an `image_url` draws it as a square thumbnail before its text in the dropdown (in place of its `icon_svg`). Set to false to render option rows without pictures. */
1378
1384
  showOptionImages?: boolean;
1379
1385
  /** When true (default), an option that carries an `item_count` shows it as a muted label at the row's trailing edge ("12 items"). Set to false to hide the counts. */
@@ -1693,6 +1699,22 @@ declare class AIAutocomplete {
1693
1699
  * Returns true when a param was reconciled (caller should `preventDefault`).
1694
1700
  */
1695
1701
  removeParamAtCaret(offset: number): boolean;
1702
+ /**
1703
+ * Take a whole chip out of the text: its span, the space seam it leaves
1704
+ * (so the surrounding words don't end up double-spaced), and its param.
1705
+ * Shared by Backspace at a chip's trailing edge and the chip's "×".
1706
+ */
1707
+ private removeWholeChip;
1708
+ /**
1709
+ * Remove a completed chip by id — the chip's "×" (`showChipRemove`). Same
1710
+ * result as Backspace at the chip's trailing edge: the chip's text and the
1711
+ * space seam it leaves come out, and any re-edit open closes first. The
1712
+ * caret follows only when the editor has focus, so a "×" pressed on an
1713
+ * unfocused editor does not pull focus into it.
1714
+ * Any value of one multi_select answer names its joined chip. Returns true
1715
+ * when a chip was removed; false (and nothing changes) when none has that id.
1716
+ */
1717
+ removeParam(paramId: string): boolean;
1696
1718
  /**
1697
1719
  * ArrowLeft while the caret sits at a completed pill's trailing edge selects
1698
1720
  * the pill rather than moving the caret into it: re-edit turns on, the pill
@@ -1860,6 +1882,13 @@ declare class AIAutocomplete {
1860
1882
  private isReEditing;
1861
1883
  /** The words typed for the place: after the last chip and any span recognized as another parameter. */
1862
1884
  private typedLocationPhrase;
1885
+ /**
1886
+ * The segments, counting the spans the server recognized that are not
1887
+ * chips yet: with `commitOnWordEnd` a recognized word waits for its space,
1888
+ * and it is another question's answer from the moment it is recognized
1889
+ * ("paris" in "flight to paris" is the destination, not where to leave from).
1890
+ */
1891
+ private segmentsWithPending;
1863
1892
  private runLocationSearch;
1864
1893
  private cancelLocationSearch;
1865
1894
  /**
@@ -2439,6 +2468,28 @@ declare function sameOptionRows(measured: readonly {
2439
2468
  text: string;
2440
2469
  }[]): boolean;
2441
2470
 
2471
+ /**
2472
+ * Wires the chips' remove "×" (`showChipRemove`) on an editor: one set of
2473
+ * delegated listeners on the editable, shared by the vanilla, React and
2474
+ * Angular editors, so the "×" elements carry no listener of their own. Attach
2475
+ * it only while the option is on.
2476
+ *
2477
+ * A mouse removes the chip on `pointerdown`. A finger or pen removes it on
2478
+ * `pointerup`, and only when it lifts on the same "×" within
2479
+ * `CHIP_REMOVE_TAP_SLOP` of where it landed, so a touch that drifts off or is
2480
+ * cancelled removes nothing.
2481
+ *
2482
+ * The press is cancelled so it neither moves the caret into the chip (which
2483
+ * would re-open it) nor takes focus; on iOS that takes the `touchstart` too.
2484
+ * Removing the chip re-renders the editor, so the rest of the same press
2485
+ * (`mousedown`, `click`) lands on whatever now sits under the pointer; those
2486
+ * are cancelled as well. Only that press: its `click`, or the next
2487
+ * `pointerdown`, ends it.
2488
+ *
2489
+ * Returns a cleanup that removes the listeners.
2490
+ */
2491
+ declare function attachChipRemove(editable: HTMLElement, removeParam: (paramId: string) => void): () => void;
2492
+
2442
2493
  /**
2443
2494
  * Plain-text caret utilities for contentEditable elements.
2444
2495
  *
@@ -2905,6 +2956,8 @@ interface RenderEditableArgs {
2905
2956
  * them (see startingHint.ts). Omitted or empty: the plain placeholder.
2906
2957
  */
2907
2958
  hintOptions?: readonly StartingHintOption[];
2959
+ /** Whether completed chips end in a faint "×" that removes them. Default: false. */
2960
+ showChipRemove?: boolean;
2908
2961
  }
2909
2962
  /**
2910
2963
  * Renders text segments into the contentEditable input. Completed params are
@@ -3403,4 +3456,4 @@ declare const SMART_SUGGESTION_SPARKLE_SVG: string;
3403
3456
  /** True when some pill is a question the shopper can decline. */
3404
3457
  declare function hasSkippablePill(suggestions: Suggestion[]): boolean;
3405
3458
 
3406
- 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 };
3459
+ 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, 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 };