@magicx-eng/ai-autocomplete-vanilla 0.51.1 → 0.52.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 +14 -2
- package/dist/index.d.mts +11 -6
- package/dist/index.d.ts +11 -6
- package/dist/index.js +62 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -642,7 +642,7 @@ unsub();
|
|
|
642
642
|
|
|
643
643
|
> **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, and hides it while the row shows its loading skeleton. 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.
|
|
644
644
|
|
|
645
|
-
> **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"`); a skeleton row keeps the tile's placeholder fill and hides the count. 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` (40px), rounded by `--aia-option-image-radius` (12px), spaced by `--aia-option-image-gap` (12px) and filled by `--aia-option-image-bg` (default: `--aia-skeleton-bg`)
|
|
645
|
+
> **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"`); a skeleton row keeps the tile's placeholder fill and hides the count. 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` (40px), rounded by `--aia-option-image-radius` (12px), spaced by `--aia-option-image-gap` (12px) and filled by `--aia-option-image-bg` (default: `--aia-skeleton-bg`) as a placeholder until its picture loads (and on skeleton rows, 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` (6px); 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` (12px), `--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.
|
|
646
646
|
|
|
647
647
|
> **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`, and a skeleton row hides it. It reads `--aia-option-parameter-font-size` (12px), `--aia-option-parameter-color` and `--aia-option-parameter-opacity` (0.6).
|
|
648
648
|
|
|
@@ -877,6 +877,15 @@ This is the way to embed the widget in a page whose CSS you don't control. In th
|
|
|
877
877
|
|
|
878
878
|
Override these on the container element. The variables are declared with `:where()` (zero specificity), so a value you set on the container always wins without `!important`.
|
|
879
879
|
|
|
880
|
+
The full input also accepts `--aia-input-radius` and `--aia-written-text-font-weight` on its container or an ancestor. Omit them to retain the default `10px` radius and `300` weight; changing `mode` does not reset these overrides. In dropdown-only integrations, style your own input directly.
|
|
881
|
+
|
|
882
|
+
```css
|
|
883
|
+
.my-search {
|
|
884
|
+
--aia-input-radius: 0;
|
|
885
|
+
--aia-written-text-font-weight: 500;
|
|
886
|
+
}
|
|
887
|
+
```
|
|
888
|
+
|
|
880
889
|
| Variable | Default (light) | Default (dark) | Description |
|
|
881
890
|
|---|---|---|---|
|
|
882
891
|
| `--aia-font-family` | `inherit` | `inherit` | Font used by the library. Defaults to `inherit` so the library picks up your page's font automatically. Set this to pin a specific font on the library without changing the surrounding page. |
|
|
@@ -889,12 +898,14 @@ Override these on the container element. The variables are declared with `:where
|
|
|
889
898
|
| `--aia-option-font-size` | `19px` | `19px` | Option font size |
|
|
890
899
|
| `--aia-written-text-color` | `#000000` | `#ffffff` | Input text |
|
|
891
900
|
| `--aia-written-text-font-size` | `19px` | `19px` | Input text font size |
|
|
901
|
+
| `--aia-written-text-font-weight` | `300` | `300` | Written text weight in the full input. Completed chips keep their own typography. |
|
|
892
902
|
| `--aia-caret-color` | `--aia-written-text-color` | `--aia-written-text-color` | Editor caret color. Override independently of input text color. |
|
|
893
903
|
| `--aia-submit-bg` | `#000000` | `#ffffff` | Submit button background. Solid + full-opacity at rest, even when the input is empty/disabled. |
|
|
894
904
|
| `--aia-submit-color` | `#ffffff` | `#000000` | Submit button arrow color |
|
|
895
905
|
| `--aia-submit-bg-disabled` | `--aia-submit-bg` | `--aia-submit-bg` | Submit background when disabled (empty input). Defaults to the enabled background so themed colors aren't washed out. Set this for a faded rest state. |
|
|
896
906
|
| `--aia-submit-color-disabled` | `--aia-submit-color` | `--aia-submit-color` | Submit arrow color when disabled. Defaults to the enabled color. |
|
|
897
907
|
| `--aia-border` | `rgba(17, 24, 39, 0.14)` | `#505050` | Input container border color |
|
|
908
|
+
| `--aia-input-radius` | `10px` | `10px` | Full input corner radius. Set `0` for square corners. |
|
|
898
909
|
| `--aia-shadow` | `none` | `none` | Input container elevation (box-shadow). Flat by default; set it to add one |
|
|
899
910
|
| `--aia-dropdown-offset` | `13px` | `13px` | Gap between the input box and the dropdown (the dropdown's margin toward the input). |
|
|
900
911
|
| `--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. |
|
|
@@ -907,9 +918,10 @@ Override these on the container element. The variables are declared with `:where
|
|
|
907
918
|
| `--aia-product-gap` | `8px` | `8px` | Gap between product cards. |
|
|
908
919
|
| `--aia-product-bg` | `transparent` | `transparent` | Product card background. |
|
|
909
920
|
| `--aia-product-bg-active` | `--aia-option-bg` | `--aia-option-bg` | Product card background on hover. |
|
|
910
|
-
| `--aia-product-media-bg` | `--aia-skeleton-bg` | `--aia-skeleton-bg` |
|
|
921
|
+
| `--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. |
|
|
911
922
|
| `--aia-scroll-arrow-color` | `--aia-option-color` | `--aia-option-color` | Chevron color of the arrow (`--aia-scroll-arrow-color-hover` on hover). |
|
|
912
923
|
| `--aia-placeholder-fade` | `120ms` | `120ms` | Fade-out of the outgoing placeholder phrase when the starting-state placeholder changes (the incoming one types itself in). |
|
|
924
|
+
| `--aia-product-image-radius` | `8px` | `8px` | 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 8px corners. |
|
|
913
925
|
| `--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. |
|
|
914
926
|
| `--aia-product-title-color` | `--aia-option-color-selected` | `--aia-option-color-selected` | Product title text. Follows the option colors by default, so theming the panel moves suggestions and products together. |
|
|
915
927
|
| `--aia-product-price-color` | `--aia-option-color-selected` | `--aia-option-color-selected` | Product price text. |
|
package/dist/index.d.mts
CHANGED
|
@@ -2392,12 +2392,17 @@ declare function productImageSrc(url: string | null | undefined): string | undef
|
|
|
2392
2392
|
* viewport by default, iOS Safari never resizes the layout one), so
|
|
2393
2393
|
* `innerHeight` alone would never see the keyboard.
|
|
2394
2394
|
*
|
|
2395
|
-
*
|
|
2396
|
-
*
|
|
2397
|
-
*
|
|
2398
|
-
*
|
|
2399
|
-
*
|
|
2400
|
-
*
|
|
2395
|
+
* A fitted panel goes back to the normal layout as soon as that layout fits
|
|
2396
|
+
* again: a window enlarged or zoomed out, the keyboard closed, the page
|
|
2397
|
+
* scrolled, a shorter question. The two layouts are not interchangeable even
|
|
2398
|
+
* when the space is there: fitting lifts the options grid's row cap, so a
|
|
2399
|
+
* long option list is drawn in full and pushes the product strip below the
|
|
2400
|
+
* fold (2026-11-04, a dashboard preview zoomed out to 50% kept its fitted
|
|
2401
|
+
* panel and the strip was out of sight). Measuring the normal layout means
|
|
2402
|
+
* dropping the attribute for one synchronous read — nothing paints in
|
|
2403
|
+
* between — and restoring the stack's scroll if the panel stays fitted. That
|
|
2404
|
+
* height depends on the content, not the space, so it is measured once per
|
|
2405
|
+
* content and only compared on the scroll and resize frames that follow.
|
|
2401
2406
|
*
|
|
2402
2407
|
* The DOM differs per package, so like the scroll arrow the behaviour lives in
|
|
2403
2408
|
* this one controller: each package hands it its dropdown element and a way
|
package/dist/index.d.ts
CHANGED
|
@@ -2392,12 +2392,17 @@ declare function productImageSrc(url: string | null | undefined): string | undef
|
|
|
2392
2392
|
* viewport by default, iOS Safari never resizes the layout one), so
|
|
2393
2393
|
* `innerHeight` alone would never see the keyboard.
|
|
2394
2394
|
*
|
|
2395
|
-
*
|
|
2396
|
-
*
|
|
2397
|
-
*
|
|
2398
|
-
*
|
|
2399
|
-
*
|
|
2400
|
-
*
|
|
2395
|
+
* A fitted panel goes back to the normal layout as soon as that layout fits
|
|
2396
|
+
* again: a window enlarged or zoomed out, the keyboard closed, the page
|
|
2397
|
+
* scrolled, a shorter question. The two layouts are not interchangeable even
|
|
2398
|
+
* when the space is there: fitting lifts the options grid's row cap, so a
|
|
2399
|
+
* long option list is drawn in full and pushes the product strip below the
|
|
2400
|
+
* fold (2026-11-04, a dashboard preview zoomed out to 50% kept its fitted
|
|
2401
|
+
* panel and the strip was out of sight). Measuring the normal layout means
|
|
2402
|
+
* dropping the attribute for one synchronous read — nothing paints in
|
|
2403
|
+
* between — and restoring the stack's scroll if the panel stays fitted. That
|
|
2404
|
+
* height depends on the content, not the space, so it is measured once per
|
|
2405
|
+
* content and only compared on the scroll and resize frames that follow.
|
|
2401
2406
|
*
|
|
2402
2407
|
* The DOM differs per package, so like the scroll arrow the behaviour lives in
|
|
2403
2408
|
* this one controller: each package hands it its dropdown element and a way
|