@magicx-eng/ai-autocomplete-angular 0.52.1 → 0.52.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 +6 -6
- package/REFERENCE.md +10 -4
- package/esm2020/lib/ai-autocomplete/ai-autocomplete.component.mjs +3 -3
- package/esm2020/lib/ai-autocomplete-dropdown/ai-autocomplete-dropdown.component.mjs +11 -7
- package/esm2020/lib/internal/pill-list/pill-list.component.mjs +3 -3
- package/esm2020/lib/internal/suggestion-grid/suggestion-grid.component.mjs +6 -2
- package/esm2020/lib/internal/suggestion-item/suggestion-item.component.mjs +3 -3
- package/fesm2015/magicx-eng-ai-autocomplete-angular.mjs +20 -12
- package/fesm2015/magicx-eng-ai-autocomplete-angular.mjs.map +1 -1
- package/fesm2020/magicx-eng-ai-autocomplete-angular.mjs +20 -12
- package/fesm2020/magicx-eng-ai-autocomplete-angular.mjs.map +1 -1
- package/lib/ai-autocomplete-dropdown/ai-autocomplete-dropdown.component.d.ts +2 -2
- package/lib/ai-autocomplete-dropdown/ai-autocomplete-dropdown.component.d.ts.map +1 -1
- package/lib/internal/suggestion-grid/suggestion-grid.component.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -64,7 +64,7 @@ To get a key, create your product at https://ai-autocomplete.com/edit/logic (it
|
|
|
64
64
|
- **Product strip:** a row of product cards under the options, from your catalog or from your own search.
|
|
65
65
|
- **Option overrides:** supply a parameter's options yourself, as a fixed list, a computed one, or results from your own endpoint.
|
|
66
66
|
- **Catalog report:** each response says which of the query's constraints the catalog applied, which it dropped, and how many items are left.
|
|
67
|
-
- **Motion:** the picked option presses in, new details shimmer, and
|
|
67
|
+
- **Motion:** the picked option presses in, new details shimmer, and the options fade out while a request is in flight.
|
|
68
68
|
- **Input handling:** keyboard navigation, the ARIA combobox 1.2 pattern, and IME-safe typing.
|
|
69
69
|
- **Auth:** a public key, or short-lived access tokens with automatic refresh and one retry on a 401.
|
|
70
70
|
- **Styling:** light and dark themes, CSS variables and stable `data-aia-*` selector hooks. It uses your page's font unless you set `--aia-font-family`.
|
|
@@ -323,9 +323,9 @@ export class SearchComponent implements OnInit, OnDestroy {
|
|
|
323
323
|
|
|
324
324
|
> **Location search in a custom UI.** For a location pill, `dd.formatType` is `"location"`, `dd.suggestions[0].options` is empty, and `dd.locationView` holds `{ query, places, status, highlighted }`. Call `ac.setLocationQuery(text)` as the user types (the SDK debounces and cancels the searches), `ac.moveLocationHighlight(±1)` for the arrow keys and `ac.commitLocation(index?)` to answer. Call `ac.setLocationFieldFocused(true)` *before* moving focus into your field (and `false` when it leaves), so the input's blur doesn't close the panel.
|
|
325
325
|
|
|
326
|
-
> **Option icons.** An option may carry an icon: `icon_svg` is inline SVG markup and `icon` its name. The built-in dropdown draws the SVG before the option's text, in the text color
|
|
326
|
+
> **Option icons.** An option may carry an icon: `icon_svg` is inline SVG markup and `icon` its name. The built-in dropdown draws the SVG before the option's text, in the text color. When rendering options yourself, pass `icon_svg` through the exported `sanitizeOptionIconSvg` before inserting it — it reduces the markup to plain vector drawing and returns `null` for anything else — and use `optionLabel(option)` for the text — it is the option's `text` alone; `icon` is the icon's name and is never shown as text, even when `icon_svg` is missing or fails to draw. A picked option's `icon` / `icon_svg` are copied onto its completed parameter, and the chip in the input draws the glyph before its text. Both surfaces can be switched off: `showOptionIcons: false` renders option rows as text only and `showChipIcons: false` renders chips as text only; either way the icon element is omitted rather than hidden.
|
|
327
327
|
|
|
328
|
-
> **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"`)
|
|
328
|
+
> **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.
|
|
329
329
|
|
|
330
330
|
## Convenience NgModule
|
|
331
331
|
|
|
@@ -367,7 +367,7 @@ Standalone-first apps don't need this — import the components/directive direct
|
|
|
367
367
|
| `prependPlaceholder` | `boolean` | `true` | `false`: hint only. |
|
|
368
368
|
| `showNonTappableOptions` | `boolean` | `true` | When `true`, non-tappable options are rendered alongside tappable ones in the dropdown. Set to `false` to hide non-tappable options entirely. |
|
|
369
369
|
| `locationSearch` | `boolean` | `true` | When `true`, a location parameter without options searches places as the user types in its field. Set to `false` to take typed text only. See [Location search](#location-search). |
|
|
370
|
-
| `showSkipButton` | `boolean` | `true` | When `true`, the dropdown's pill bar ends in a small "skip" button that dismisses the active pill — same action as pressing <kbd>→</kbd> at the end of the input. It
|
|
370
|
+
| `showSkipButton` | `boolean` | `true` | When `true`, the dropdown's pill bar ends in a small "skip" button that dismisses the active pill — same action as pressing <kbd>→</kbd> at the end of the input. It sits at the header's trailing edge, across from the label, once the input has text. Set to `false` to hide it. |
|
|
371
371
|
| `showOptionIcons` | `boolean` | `true` | When `true`, an option that carries an `icon_svg` draws its icon before its text in the dropdown. Set to `false` to render option rows as text only. |
|
|
372
372
|
| `showChipIcons` | `boolean` | `true` | When `true`, a completed chip in the input draws the icon of the option that answered it. Set to `false` to render chips as text only. |
|
|
373
373
|
| `showChipImages` | `boolean` | `true` | When `true`, 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. |
|
|
@@ -706,7 +706,7 @@ For styling beyond the CSS variables, target these stable `data-aia-*` attribute
|
|
|
706
706
|
| `[data-aia-pill]` | Each unfilled-suggestion pill |
|
|
707
707
|
| `[data-aia-pillbar]` | Pill bar container inside the dropdown |
|
|
708
708
|
| `[data-aia-pill-scroll]` | Scrollable pill region inside the bar — carries the horizontal scroll and right-edge fade mask |
|
|
709
|
-
| `[data-aia-skip]` | The pill bar's "skip" button:
|
|
709
|
+
| `[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` |
|
|
710
710
|
| `[data-aia-option]` | Each suggestion option |
|
|
711
711
|
| `[data-aia-scroll-arrow]` | The "more below" arrow on the dropdown — carries `data-aia-visible` while shown |
|
|
712
712
|
| `[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)). |
|
|
@@ -768,7 +768,7 @@ Submits from Enter and from `<ai-autocomplete>`'s built-in button are recorded f
|
|
|
768
768
|
|
|
769
769
|
## Option Overrides
|
|
770
770
|
|
|
771
|
-
Supply the options for a parameter yourself instead of taking the server's. Each entry is keyed by the suggestion `parameter` and is a function of the phrase the user has typed for that parameter — return an array for a fixed or computed list, or a promise for one that lives behind a request (the dropdown shows its loading
|
|
771
|
+
Supply the options for a parameter yourself instead of taking the server's. Each entry is keyed by the suggestion `parameter` and is a function of the phrase the user has typed for that parameter — return an array for a fixed or computed list, or a promise for one that lives behind a request (the dropdown shows its loading state until it settles). Bind a component field, not an inline literal: the input is forwarded on reference change.
|
|
772
772
|
|
|
773
773
|
```ts
|
|
774
774
|
import type { OptionOverrides } from "@magicx-eng/ai-autocomplete-angular";
|
package/REFERENCE.md
CHANGED
|
@@ -470,6 +470,10 @@ locations is the server's call: it marks them `type: { kind: "location" }`.
|
|
|
470
470
|
- **Without options**, the dropdown shows a search field instead. Typing in it
|
|
471
471
|
searches places through the MagicX server, which proxies a location provider,
|
|
472
472
|
and lists what it finds; any city, address or landmark can be picked.
|
|
473
|
+
What the user types in the main input is searched there too, cut to its
|
|
474
|
+
place-name end ("going to paris" searches "paris"; "to san fran" searches
|
|
475
|
+
"san fran"). Typing in the field itself takes over until it loses focus, and
|
|
476
|
+
an input that holds no place name never clears the field.
|
|
473
477
|
|
|
474
478
|
Nothing is required to switch it on. The field searches
|
|
475
479
|
`…/locations/autocomplete`, next to your `/suggest` endpoint
|
|
@@ -550,14 +554,15 @@ The full input also accepts `--aia-input-radius` and `--aia-written-text-font-we
|
|
|
550
554
|
| `--aia-submit-bg-ready` | `--aia-submit-bg` | `--aia-submit-bg` | Submit background once the request is complete (the button also lifts slightly). Defaults to the enabled background. |
|
|
551
555
|
| `--aia-submit-color` | `#ffffff` | `#000000` | Submit button icon color |
|
|
552
556
|
| `--aia-dropdown-bg` | — | — | Optional bg color the dropdown's "glass" rim shadow tints toward. Set this to the page background behind the dropdown so the bottom-corner glow blends seamlessly. |
|
|
553
|
-
| `--aia-scrollbar-
|
|
557
|
+
| `--aia-scrollbar-track` | `rgba(15, 23, 42, 0.05)` | `rgba(255, 255, 255, 0.08)` | The floating options box's thin scrollbar track, shown while a long list overflows. |
|
|
558
|
+
| `--aia-scrollbar-thumb` | `rgba(15, 23, 42, 0.22)` | `rgba(255, 255, 255, 0.28)` | That scrollbar's thumb. |
|
|
554
559
|
| `--aia-streak-rgb` | `99, 102, 241` | `255, 255, 255` | Comma-separated RGB triplet tinting the datepicker's pressed cell, and its selected cell when `--aia-date-selected-bg` is unset. The today ring uses `--aia-date-today-ring`, not this. |
|
|
555
560
|
| `--aia-product-card-width` | `81.2px` | `81.2px` | Width of a product card in the strip. The media tile is square, so this also sets its height. |
|
|
556
561
|
| `--aia-product-gap` | `5.6px` | `5.6px` | Gap between product cards. |
|
|
557
562
|
| `--aia-product-bg` | `transparent` | `transparent` | Product card background. |
|
|
558
563
|
| `--aia-product-bg-active` | `--aia-option-bg` | `--aia-option-bg` | Product card background on hover. |
|
|
559
564
|
| `--aia-product-media-bg` | `--aia-skeleton-bg` | `--aia-skeleton-bg` | Placeholder fill of the product tile: shown until the photo loads, and behind both fallback tiles (placeholder pictogram or title initial) used when an image URL is missing, blank or fails to load. Once a photo loads the tile is transparent. |
|
|
560
|
-
| `--aia-scroll-arrow-color` | `--aia-option-color` | `--aia-option-color` | Chevron color of the arrow (`--aia-scroll-arrow-color-hover` on hover). |
|
|
565
|
+
| `--aia-scroll-arrow-color` | `--aia-option-color` | `--aia-option-color` | Chevron color of the arrow (`--aia-scroll-arrow-color-hover` on hover). `optionsStyle: "classic"` only: the floating box draws a thin scrollbar instead (`--aia-scrollbar-*`). |
|
|
561
566
|
| `--aia-placeholder-fade` | `120ms` | `120ms` | Fade-out of the outgoing placeholder phrase when the starting-state placeholder changes (the incoming one types itself in). |
|
|
562
567
|
| `--aia-product-image-radius` | `5.6px` | `5.6px` | Corner radius of a product photo narrower than its square tile (a tall one), which is scaled to fit rather than cropped. A photo that fills the tile takes the tile's own 5.6px corners. |
|
|
563
568
|
| `--aia-product-placeholder-image` | storefront pictogram | storefront pictogram | The pictogram used by `productImageFallback: "image"` (the default) when an image URL is missing, blank or fails to load. Defaults to a two-tone storefront inlined as a data URI. Set any `url(...)` to swap it; it is centered and contained over `--aia-product-media-bg`. Does not affect `"initial"` tiles. |
|
|
@@ -590,7 +595,8 @@ The full input also accepts `--aia-input-radius` and `--aia-written-text-font-we
|
|
|
590
595
|
| `--aia-confirm-color` | `#ffffff` | `#000000` | The checkbox's checkmark (and, in dark mode, the Done buttons' text). |
|
|
591
596
|
| `--aia-done-bg` / `--aia-done-bg-hover` / `--aia-done-color` | `#e4e8f0` / `#d8dde8` / `#2a3150` | `--aia-confirm-*` | The Done buttons (multi-select and time wheel). |
|
|
592
597
|
| `--aia-multi-done-bg` / `--aia-multi-done-bg-hover` / `--aia-multi-done-color` | `--aia-done-*` | `--aia-done-*` | Override the multi-select Done button alone. |
|
|
593
|
-
| `--aia-multi-done-width` | as wide as the widest option | same | Width of the multi-select Done button
|
|
598
|
+
| `--aia-multi-done-width` | `100%` (classic: as wide as the widest option) | same | Width of the multi-select Done button. |
|
|
599
|
+
| `--aia-panel-min-width` | `160px` | same | Narrowest the floating options box gets when it hugs its options (desktop). |
|
|
594
600
|
| `--aia-multi-done-min-width` | `120px` | `120px` | Narrowest the multi-select Done button gets. |
|
|
595
601
|
| `--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. |
|
|
596
602
|
| `--aia-location-field-bg-idle` | `transparent` | `transparent` | The location search field at rest. |
|
|
@@ -598,7 +604,7 @@ The full input also accepts `--aia-input-radius` and `--aia-written-text-font-we
|
|
|
598
604
|
| `--aia-location-field-radius` | `10px` | `10px` | Corner radius of the location search field. |
|
|
599
605
|
| `--aia-location-font-size` | `15px` | `15px` | The location field's text and the place names. |
|
|
600
606
|
| `--aia-location-row-bg-highlighted` | `--aia-streak-rgb` at 8% (indigo) | `--aia-streak-rgb` at 8% (white) | The highlighted (or hovered) place. |
|
|
601
|
-
| `--aia-skeleton-bg` | `rgba(189, 189, 189, 0.083)` | `#1a1b1d` | Fill color
|
|
607
|
+
| `--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). |
|
|
602
608
|
| `--aia-content-inset-left` | `16px` | `16px` | Left inset of the SDK's content: the input wrapper's left padding, and the line the dropdown's content (parameter label, option text, product strip) starts on. Set it when you pad the field to clear a leading icon of your own, so the dropdown's content stays aligned under the typed text. Practical minimum is `10px` (the option text's own inset); both surfaces floor it there. |
|
|
603
609
|
| `--aia-footer-chip-bg` | `--aia-surface` at 65% | `--aia-surface` at 65% | Fill behind the footer's keyboard hint and AI-Autocomplete badge. The option list scrolls under the footer, so this keeps both legible over the row passing behind them. `transparent` on the glass surface. |
|
|
604
610
|
|