@magicx-eng/ai-autocomplete-vanilla 0.72.1 → 0.72.2

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,7 +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
+ showChipRemove: false, // true = each chip ends in a small faint × that removes it in one tap
119
119
  showOptionImages: true, // false = never draw an option's image_url thumbnail
120
120
  showOptionCounts: true, // false = never show an option's item_count
121
121
 
@@ -351,7 +351,7 @@ unsub();
351
351
 
352
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.
353
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).
354
+ > **Removing a chip.** With `showChipRemove: true`, every 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). Chips the server identified in typed text get one too. The × reads `--aia-chip-remove-opacity` (0.32) and `--aia-chip-remove-opacity-hover` (0.7).
355
355
 
356
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).
357
357
 
@@ -397,7 +397,7 @@ unsub();
397
397
  | `setActivePill(index)` | Reorder pills — moves pill at `index` to front (active). |
398
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`). |
399
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. |
400
+ | `removeParam(paramId)` | Remove the chip with that id (completed or identified), 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 chip has that id. |
401
401
  | `clearNewParamId()` | Clear shimmer animation state. |
402
402
  | `reset()` | Clear all state, re-fetch initial suggestions, and start a new session (rotates `session_id`). Call this after handling submit. |
403
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
@@ -603,17 +603,18 @@ The full input also accepts `--aia-input-radius` and `--aia-written-text-font-we
603
603
  | `--aia-confirm-color` | `#ffffff` | `#000000` | The checkbox's checkmark (and, in dark mode, the Done buttons' text). |
604
604
  | `--aia-done-bg` / `--aia-done-bg-hover` / `--aia-done-color` | `#e4e8f0` / `#d8dde8` / `#2a3150` | `--aia-confirm-*` | The Done buttons (multi-select and time wheel). |
605
605
  | `--aia-multi-done-bg` / `--aia-multi-done-bg-hover` / `--aia-multi-done-color` | `--aia-done-*` | `--aia-done-*` | Override the multi-select Done button alone. |
606
+ | `--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. |
606
607
  | `--aia-multi-done-width` | `100%` (classic: as wide as the widest option) | same | Width of the multi-select Done button. |
607
608
  | `--aia-panel-min-width` | `160px` | same | Narrowest the floating options box gets when it hugs its options (desktop). |
608
609
  | `--aia-multi-done-min-width` | `120px` | `120px` | Narrowest the multi-select Done button gets. |
609
610
  | `--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. |
610
- | `--aia-see-all-bg` / `--aia-see-all-bg-hover` / `--aia-see-all-color` | `#111111` / `#333333` / `#ffffff` | `--aia-confirm-*` | The "See all results" button (`seeAllResults`). |
611
- | `--aia-see-all-height` / `--aia-see-all-radius` / `--aia-see-all-font-size` | `48px` / `999px` / `16px` | same | Its minimum height, corner radius and text size. |
611
+ | `--aia-see-all-bg` / `--aia-see-all-bg-hover` / `--aia-see-all-color` | `#2b2b2b` / `#3d3d3d` / `#ffffff` | `--aia-confirm-*` | The "See all results" button (`seeAllResults`). |
612
+ | `--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. |
612
613
  | `--aia-location-field-bg-idle` | `transparent` | `transparent` | The location search field at rest. |
613
614
  | `--aia-location-field-bg` | `--aia-streak-rgb` at 6% (indigo) | `--aia-streak-rgb` at 6% (white) | The location search field on hover or focus. |
614
615
  | `--aia-location-field-radius` | `10px` | `10px` | Corner radius of the location search field. |
615
616
  | `--aia-location-font-size` | `15px` | `15px` | The location field's text and the place names. |
616
617
  | `--aia-location-row-bg-highlighted` | `--aia-streak-rgb` at 8% (indigo) | `--aia-streak-rgb` at 8% (white) | The highlighted (or hovered) place. |
617
618
  | `--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` | `0.32` | `0.32` | Opacity of a 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
620
  | `--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
@@ -1042,6 +1042,12 @@ interface CoreInputState {
1042
1042
  * pill at pick time (or the pill being re-edited). See `dropdownSuggestion`.
1043
1043
  */
1044
1044
  skeletonSuggestion: Suggestion | null;
1045
+ /**
1046
+ * For a multi-select answer, the values that were ticked when Done was
1047
+ * pressed, so the mirrored checkbox list fades out still showing them.
1048
+ * Null otherwise.
1049
+ */
1050
+ skeletonPicked: string[] | null;
1045
1051
  /**
1046
1052
  * Whether the answer's request has started since `skeletonOptions` was set.
1047
1053
  * Lets the derive layer tell "the request settled" (fade the skeleton out)
@@ -1209,6 +1215,15 @@ interface CoreDerivedState {
1209
1215
  multiSelectView: {
1210
1216
  picked: string[];
1211
1217
  } | null;
1218
+ /**
1219
+ * The checkbox list the dropdown draws: `multiSelectView`, or, while a
1220
+ * multi_select answer's request loads, that question's list with the values
1221
+ * Done sent still ticked, so it fades out with the rest of the dropdown
1222
+ * instead of vanishing. Render-only; handlers read `multiSelectView`.
1223
+ */
1224
+ dropdownMultiSelect: {
1225
+ picked: string[];
1226
+ } | null;
1212
1227
  /**
1213
1228
  * What the location search field shows. Null unless `activeFormatType` is
1214
1229
  * `"location"` (a location parameter that came with no options).
@@ -1375,7 +1390,8 @@ interface CoreOptions {
1375
1390
  /** 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
1391
  showChipImages?: boolean;
1377
1392
  /**
1378
- * When true, every completed chip in the input ends in a small, faint "×"
1393
+ * When true, every chip in the input (completed, or identified by the
1394
+ * server in typed text) ends in a small, faint "×"
1379
1395
  * that removes the chip in one tap (the same result as Backspace at the
1380
1396
  * chip's trailing edge). Default: false.
1381
1397
  */
@@ -1706,13 +1722,16 @@ declare class AIAutocomplete {
1706
1722
  */
1707
1723
  private removeWholeChip;
1708
1724
  /**
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.
1725
+ * Remove a chip by id — the chip's "×" (`showChipRemove`). Same result as
1726
+ * Backspace at the chip's trailing edge: the chip's text and the space seam
1727
+ * it leaves come out, and any re-edit open closes first. The caret follows
1728
+ * only when the editor has focus, so a "×" pressed on an unfocused editor
1729
+ * does not pull focus into it.
1730
+ * Both chip kinds are removed: a completed chip (a picked option) and an
1731
+ * identified one (words the server recognised) look the same, so both carry
1732
+ * the "×". Any value of one multi_select answer names its joined chip.
1733
+ * Returns true when a chip was removed; false (and nothing changes) when
1734
+ * none has that id.
1716
1735
  */
1717
1736
  removeParam(paramId: string): boolean;
1718
1737
  /**
@@ -2956,7 +2975,7 @@ interface RenderEditableArgs {
2956
2975
  * them (see startingHint.ts). Omitted or empty: the plain placeholder.
2957
2976
  */
2958
2977
  hintOptions?: readonly StartingHintOption[];
2959
- /** Whether completed chips end in a faint "×" that removes them. Default: false. */
2978
+ /** Whether chips (completed and identified) end in a faint "×" that removes them. Default: false. */
2960
2979
  showChipRemove?: boolean;
2961
2980
  }
2962
2981
  /**
package/dist/index.d.ts CHANGED
@@ -1042,6 +1042,12 @@ interface CoreInputState {
1042
1042
  * pill at pick time (or the pill being re-edited). See `dropdownSuggestion`.
1043
1043
  */
1044
1044
  skeletonSuggestion: Suggestion | null;
1045
+ /**
1046
+ * For a multi-select answer, the values that were ticked when Done was
1047
+ * pressed, so the mirrored checkbox list fades out still showing them.
1048
+ * Null otherwise.
1049
+ */
1050
+ skeletonPicked: string[] | null;
1045
1051
  /**
1046
1052
  * Whether the answer's request has started since `skeletonOptions` was set.
1047
1053
  * Lets the derive layer tell "the request settled" (fade the skeleton out)
@@ -1209,6 +1215,15 @@ interface CoreDerivedState {
1209
1215
  multiSelectView: {
1210
1216
  picked: string[];
1211
1217
  } | null;
1218
+ /**
1219
+ * The checkbox list the dropdown draws: `multiSelectView`, or, while a
1220
+ * multi_select answer's request loads, that question's list with the values
1221
+ * Done sent still ticked, so it fades out with the rest of the dropdown
1222
+ * instead of vanishing. Render-only; handlers read `multiSelectView`.
1223
+ */
1224
+ dropdownMultiSelect: {
1225
+ picked: string[];
1226
+ } | null;
1212
1227
  /**
1213
1228
  * What the location search field shows. Null unless `activeFormatType` is
1214
1229
  * `"location"` (a location parameter that came with no options).
@@ -1375,7 +1390,8 @@ interface CoreOptions {
1375
1390
  /** 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
1391
  showChipImages?: boolean;
1377
1392
  /**
1378
- * When true, every completed chip in the input ends in a small, faint "×"
1393
+ * When true, every chip in the input (completed, or identified by the
1394
+ * server in typed text) ends in a small, faint "×"
1379
1395
  * that removes the chip in one tap (the same result as Backspace at the
1380
1396
  * chip's trailing edge). Default: false.
1381
1397
  */
@@ -1706,13 +1722,16 @@ declare class AIAutocomplete {
1706
1722
  */
1707
1723
  private removeWholeChip;
1708
1724
  /**
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.
1725
+ * Remove a chip by id — the chip's "×" (`showChipRemove`). Same result as
1726
+ * Backspace at the chip's trailing edge: the chip's text and the space seam
1727
+ * it leaves come out, and any re-edit open closes first. The caret follows
1728
+ * only when the editor has focus, so a "×" pressed on an unfocused editor
1729
+ * does not pull focus into it.
1730
+ * Both chip kinds are removed: a completed chip (a picked option) and an
1731
+ * identified one (words the server recognised) look the same, so both carry
1732
+ * the "×". Any value of one multi_select answer names its joined chip.
1733
+ * Returns true when a chip was removed; false (and nothing changes) when
1734
+ * none has that id.
1716
1735
  */
1717
1736
  removeParam(paramId: string): boolean;
1718
1737
  /**
@@ -2956,7 +2975,7 @@ interface RenderEditableArgs {
2956
2975
  * them (see startingHint.ts). Omitted or empty: the plain placeholder.
2957
2976
  */
2958
2977
  hintOptions?: readonly StartingHintOption[];
2959
- /** Whether completed chips end in a faint "×" that removes them. Default: false. */
2978
+ /** Whether chips (completed and identified) end in a faint "×" that removes them. Default: false. */
2960
2979
  showChipRemove?: boolean;
2961
2980
  }
2962
2981
  /**