@magicx-eng/ai-autocomplete-angular 0.65.4 → 0.65.6

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
@@ -214,7 +214,7 @@ A suggestion with `type: { kind: "multi_select" }` shows checkbox options and a
214
214
 
215
215
  ### Location search
216
216
 
217
- A location parameter the server sends without options gets a search field that looks up any city or address through the MagicX server. If `apiConfig.endpoint` points at a proxy with its own path, set `apiConfig.locationEndpoint` too. `locationSearch: false` takes typed text only, and an `optionOverrides` entry for the parameter replaces the search. Details: [REFERENCE.md](https://unpkg.com/@magicx-eng/ai-autocomplete-angular/REFERENCE.md), under "Location search".
217
+ A location parameter the server sends without options gets a search field that looks up any city or address through the location search endpoint (the hosted service's by default). If `apiConfig.endpoint` points at a proxy with its own path, set `apiConfig.locationEndpoint` too. `locationSearch: false` takes typed text only, and an `optionOverrides` entry for the parameter replaces the search. Details: [REFERENCE.md](https://unpkg.com/@magicx-eng/ai-autocomplete-angular/REFERENCE.md), under "Location search"; to replace every endpoint, see "Using your own server" there.
218
218
 
219
219
  ## Tier 2: Controller + Dropdown
220
220
 
@@ -416,7 +416,7 @@ The dropdown shows a row of product cards under the options whenever there are p
416
416
 
417
417
  Each response that read the catalog says which of the query's constraints it applied (`applied_filters`), which it dropped (`dropped_filters`) and how many items are left (`items.total`). Read it from `customFields$` on the controller, or from `custom_fields` on `AutocompleteResult`. `null` means no catalog was read for that response. Details: [REFERENCE.md](https://unpkg.com/@magicx-eng/ai-autocomplete-angular/REFERENCE.md), under "The catalog report".
418
418
 
419
- When the search finds no item, `blocking_filters` names each condition whose removal finds items, with the count. The SDK greys out those chips and gives each a "×" that removes it, even with `showChipRemove` off. The chips are `blockingChips` on the controller state; the opacity is the `--aia-blocking-chip-opacity` token (default `0.5`).
419
+ When the search finds no item, `blocking_filters` names each condition whose removal finds items, with the count. The SDK gives each of those chips a "×" that removes it, even with `showChipRemove` off; the chips look the same as every other chip. The chips are `blockingChips` on the controller state, and each carries the class `magicx-aia-segment--blocking` for a page that wants to style them.
420
420
 
421
421
  #### Change product cards before display
422
422
 
@@ -457,6 +457,9 @@ A discriminated union: `APIKeyConfig | AccessTokenConfig`.
457
457
  | `apiKey?` | `string` | API key for Authorization header. |
458
458
  | `authScheme?` | `"Bearer" \| "Basic"` | Auth header scheme. Default: `"Bearer"`. |
459
459
  | `endpoint?` | `string` | Full URL for the suggest endpoint. Default: `"https://api.ai-autocomplete.com/api/suggest"`. |
460
+ | `locationEndpoint?` | `string` | Location search URL. Default: beside `endpoint` (`…/suggest` → `…/locations/autocomplete`). |
461
+ | `telemetryEndpoint?` | `string` | Telemetry events URL. Default: beside `endpoint` (`…/suggest` → `…/telemetry/events`). |
462
+ | `startingStateEndpoint?` | `string` | Base URL the starting state is read from (`{base}/{productId}/{language}`). Default: beside `endpoint` (`…/suggest` → `…/starting-state`). |
460
463
  | `appIdentifier?` | `string` | Value for the `X-App-Identifier` header. |
461
464
  | `headers?` | `Record<string, string>` | Additional headers merged into every request. |
462
465
 
@@ -487,6 +490,9 @@ apiConfig: AccessTokenConfig = {
487
490
  | `getAccessToken` | `() => Promise<AccessTokenResult>` | **Required.** Called when the SDK needs a token. |
488
491
  | `accessToken?` | `string` | Initial token. Avoids one round-trip on mount. |
489
492
  | `endpoint?` | `string` | Suggest endpoint URL. Default: `"https://api.ai-autocomplete.com/api/suggest"`. |
493
+ | `locationEndpoint?` | `string` | Location search URL. Default: beside `endpoint` (`…/suggest` → `…/locations/autocomplete`). |
494
+ | `telemetryEndpoint?` | `string` | Telemetry events URL. Default: beside `endpoint` (`…/suggest` → `…/telemetry/events`). |
495
+ | `startingStateEndpoint?` | `string` | Base URL the starting state is read from (`{base}/{productId}/{language}`). Default: beside `endpoint` (`…/suggest` → `…/starting-state`). |
490
496
  | `appIdentifier?` | `string` | Value for the `X-App-Identifier` header. |
491
497
  | `headers?` | `Record<string, string>` | Additional headers merged into every request. |
492
498
 
@@ -703,48 +709,7 @@ On a phone or tablet, the shopper can put the keyboard away to see the whole dro
703
709
 
704
710
  ### Selector Hooks
705
711
 
706
- For styling beyond the CSS variables, target these stable `data-aia-*` attributes (component-internal class names are not part of the public API):
707
-
708
- | Attribute | Element |
709
- |---|---|
710
- | `[data-aia-input-wrapper]` | Wrapper around the editor area and the submit button — one of the two roots the SDK isolates from page CSS (the dropdown is the other) |
711
- | `[data-aia-editor]` | Editor area wrapping the contentEditable + inline pill list |
712
- | `[data-aia-input]` | The Tier 1 contentEditable `<div>` that owns typed text and bold completed params |
713
- | `[data-aia-pill-list-container]` | Inline sibling of the editor that holds unfilled-suggestion pills |
714
- | `[data-aia-submit]` | Submit button |
715
- | `[data-aia-pill]` | Each unfilled-suggestion pill |
716
- | `[data-aia-pillbar]` | Pill bar container inside the dropdown |
717
- | `[data-aia-pill-scroll]` | Scrollable pill region inside the bar — carries the horizontal scroll and right-edge fade mask |
718
- | `[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` |
719
- | `[data-aia-hint-el]` | The empty box's hint: the lead-in and the first starting options, one at a time. Tune via `--aia-hint-color` / `--aia-hint-font-weight` / `--aia-hint-icon-opacity` |
720
- | `[data-aia-option]` | Each suggestion option |
721
- | `[data-aia-scroll-arrow]` | The "more below" arrow on the dropdown — carries `data-aia-visible` while shown |
722
- | `[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)). |
723
- | `[data-aia-datepicker]` | The calendar, rendered in place of the option list for a date parameter |
724
- | `[data-aia-time-wheel]` | The time wheel, rendered in place of the option list for a time parameter |
725
- | `[data-aia-location]` | The location search, rendered in place of the option list for a location parameter without options (`[data-aia-location-input]` is its field, `[data-aia-location-row]` each place) |
726
- | `[data-aia-date-month]` | The "March 2026" header label |
727
- | `[data-aia-date-prev]` / `[data-aia-date-next]` | The month arrows |
728
- | `[data-aia-date-grid]` | The 7-column grid of day cells |
729
- | `[data-aia-date-cell]` | Each day cell. Also carries `[data-aia-option]`, so option-level styling applies to both bodies |
730
- | `[data-aia-products]` | Product strip section (label + row) |
731
- | `[data-aia-products-row]` | The horizontally scrolling row of cards |
732
- | `[data-aia-product]` | Each product card |
733
- | `[data-aia-product-placeholder]` | Media tile showing the placeholder pictogram (`productImageFallback: "image"`) after a missing/blank URL or load error. The existing hook is unchanged. |
734
- | `[data-aia-product-initial]` | The media tile itself when it shows the title initial (`productImageFallback: "initial"`). Decorative (`aria-hidden="true"`); target it to style the background, color, font size and border radius. |
735
-
736
- Completed params render as inline `<strong>` elements inside the editor. Override their weight with `[data-aia-input] strong { font-weight: 700; }`.
737
-
738
- ```css
739
- /* Solid (non-glass) dropdown */
740
- .my-autocomplete [data-aia-dropdown] {
741
- background: #fff;
742
- box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
743
- backdrop-filter: none;
744
- }
745
- ```
746
-
747
- ---
712
+ For styling beyond the CSS variables, the stable `data-aia-*` attributes to target are listed in [REFERENCE.md](https://unpkg.com/@magicx-eng/ai-autocomplete-angular/REFERENCE.md), under "Selector hooks".
748
713
 
749
714
  ## Sessions
750
715
 
@@ -823,4 +788,11 @@ The Tier 1 component renders a static shell during SSR and mounts on the client.
823
788
 
824
789
  ## License
825
790
 
826
- MIT.
791
+ The SDK in this repository is licensed under the [MIT License](./LICENSE).
792
+
793
+ By default the SDK sends requests to the hosted Intent-1 service operated by
794
+ MagicX. That server call is modular: every endpoint is configurable, and the
795
+ default can be replaced with a self-hosted or third-party server (see
796
+ ["Using your own server"](./REFERENCE.md#using-your-own-server)).
797
+
798
+ The hosted Intent-1 service is a separate service, governed by MagicX's own [Terms & Conditions](https://ai-autocomplete.com/legal/terms), not by the SDK's license. The MIT license covers the SDK code only. No rights in the hosted service or in any server-side method are granted through it.
package/REFERENCE.md CHANGED
@@ -655,8 +655,8 @@ locations is the server's call: it marks them `type: { kind: "location" }`.
655
655
  - **With options** (a catalog with a `city` field, say), it is an ordinary
656
656
  option list. Nothing changes.
657
657
  - **Without options**, the dropdown shows a search field instead. Typing in it
658
- searches places through the MagicX server, which proxies a location provider,
659
- and lists what it finds; any city, address or landmark can be picked.
658
+ searches places through the location search endpoint and
659
+ lists what it finds; any city, address or landmark can be picked.
660
660
  What the user types in the main input is searched there too, cut to its
661
661
  place-name end ("going to paris" searches "paris"; "to san fran" searches
662
662
  "san fran"). Typing in the field itself takes over until it loses focus, and
@@ -813,6 +813,7 @@ The full input also accepts `--aia-input-radius` and `--aia-written-text-font-we
813
813
  | `--aia-time-font-size` | `15px` | `15px` | The time wheel's numbers and its `:` separator. |
814
814
  | `--aia-time-band-bg` | white at 8% | white at 8% | The band behind the wheels' top rows — the chosen time. |
815
815
  | `--aia-confirm-bg` | `#262626` | `#a6a6a6` | The solid fill of a checked multi-select checkbox (and, in dark mode, of the Done buttons). |
816
+ | `--aia-checkbox-border` | the option text at 65% | the option text at 65% | Border of an unticked multi-select checkbox. Defaults to the option text colour so the box stays visible when the dropdown border is faint or transparent; a ticked box uses `--aia-confirm-bg`. |
816
817
  | `--aia-confirm-bg-hover` | `#404040` | `#b8b8b8` | The Done buttons on hover in dark mode. |
817
818
  | `--aia-confirm-color` | `#ffffff` | `#000000` | The checkbox's checkmark (and, in dark mode, the Done buttons' text). |
818
819
  | `--aia-done-bg` / `--aia-done-bg-hover` / `--aia-done-color` | `#e4e8f0` / `#d8dde8` / `#2a3150` | `--aia-confirm-*` | The Done buttons (multi-select and time wheel). |
@@ -840,6 +841,51 @@ The full input also accepts `--aia-input-radius` and `--aia-written-text-font-we
840
841
 
841
842
  Tokens for the option thumbnail, the item count and the chip's picture (the README's "Option pictures and counts" note describes what each draws). 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 (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.
842
843
 
844
+ ## Selector hooks
845
+
846
+ For styling beyond the CSS variables, target these stable `data-aia-*` attributes (component-internal class names are not part of the public API):
847
+
848
+ | Attribute | Element |
849
+ |---|---|
850
+ | `[data-aia-input-wrapper]` | Wrapper around the editor area and the submit button — one of the two roots the SDK isolates from page CSS (the dropdown is the other) |
851
+ | `[data-aia-editor]` | Editor area wrapping the contentEditable + inline pill list |
852
+ | `[data-aia-input]` | The Tier 1 contentEditable `<div>` that owns typed text and bold completed params |
853
+ | `[data-aia-pill-list-container]` | Inline sibling of the editor that holds unfilled-suggestion pills |
854
+ | `[data-aia-submit]` | Submit button |
855
+ | `[data-aia-pill]` | Each unfilled-suggestion pill |
856
+ | `[data-aia-pillbar]` | Pill bar container inside the dropdown |
857
+ | `[data-aia-pill-scroll]` | Scrollable pill region inside the bar — carries the horizontal scroll and right-edge fade mask |
858
+ | `[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` |
859
+ | `[data-aia-hint-el]` | The empty box's hint: the lead-in and the first starting options, one at a time. Tune via `--aia-hint-color` / `--aia-hint-font-weight` / `--aia-hint-icon-opacity` |
860
+ | `[data-aia-option]` | Each suggestion option |
861
+ | `[data-aia-scroll-arrow]` | The "more below" arrow on the dropdown — carries `data-aia-visible` while shown |
862
+ | `[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](./README.md#short-screens)). |
863
+ | `[data-aia-datepicker]` | The calendar, rendered in place of the option list for a date parameter |
864
+ | `[data-aia-time-wheel]` | The time wheel, rendered in place of the option list for a time parameter |
865
+ | `[data-aia-location]` | The location search, rendered in place of the option list for a location parameter without options (`[data-aia-location-input]` is its field, `[data-aia-location-row]` each place) |
866
+ | `[data-aia-date-month]` | The "March 2026" header label |
867
+ | `[data-aia-date-prev]` / `[data-aia-date-next]` | The month arrows |
868
+ | `[data-aia-date-grid]` | The 7-column grid of day cells |
869
+ | `[data-aia-date-cell]` | Each day cell. Also carries `[data-aia-option]`, so option-level styling applies to both bodies |
870
+ | `[data-aia-products]` | Product strip section (label + row) |
871
+ | `[data-aia-products-row]` | The horizontally scrolling row of cards |
872
+ | `[data-aia-product]` | Each product card |
873
+ | `[data-aia-product-placeholder]` | Media tile showing the placeholder pictogram (`productImageFallback: "image"`) after a missing/blank URL or load error. The existing hook is unchanged. |
874
+ | `[data-aia-product-initial]` | The media tile itself when it shows the title initial (`productImageFallback: "initial"`). Decorative (`aria-hidden="true"`); target it to style the background, color, font size and border radius. |
875
+
876
+ Completed params render as inline `<strong>` elements inside the editor. Override their weight with `[data-aia-input] strong { font-weight: 700; }`.
877
+
878
+ ```css
879
+ /* Solid (non-glass) dropdown */
880
+ .my-autocomplete [data-aia-dropdown] {
881
+ background: #fff;
882
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
883
+ backdrop-filter: none;
884
+ }
885
+ ```
886
+
887
+ ---
888
+
843
889
  ## Server-side rendering
844
890
 
845
891
  The package is render-blocking-safe — the Tier 1 component renders a static shell during SSR / Angular Universal, and the live autocomplete only mounts on the client. For Tier 2 (`new AIAutocompleteController(...)`), gate construction with `isPlatformBrowser`:
@@ -890,3 +936,73 @@ onSubmitted(result: AutocompleteResult) {
890
936
  ```
891
937
 
892
938
  The id of the last search the current tab handed off (a submit or a product pick) is also kept in `sessionStorage` under `aia:last-search`, as `{ id, at }`, where `at` is when it was handed off, in milliseconds since the epoch.
939
+
940
+ ## Using your own server
941
+
942
+ By default the SDK sends its requests to the hosted Intent-1 service. Every
943
+ endpoint is replaceable through `apiConfig`, so the widget can talk to your own
944
+ server, a proxy, or a third-party service instead.
945
+
946
+ | Request | Method and URL | Option | Default |
947
+ |---|---|---|---|
948
+ | Suggestions | `POST {endpoint}` | `endpoint` | the hosted service's `…/api/suggest` |
949
+ | Starting state (only with `productId`) | `GET {base}/{productId}/{language}` | `startingStateEndpoint` (the base) | beside `endpoint`: `…/starting-state` |
950
+ | Location search | `POST {locationEndpoint}` | `locationEndpoint` | beside `endpoint`: `…/locations/autocomplete` |
951
+ | Telemetry events | `POST {telemetryEndpoint}` | `telemetryEndpoint` | beside `endpoint`: `…/telemetry/events` |
952
+
953
+ On the hosted service, the starting state is served from its CDN host
954
+ (`cdn.ai-autocomplete.com`) rather than the API host, so an allowlist for the
955
+ default setup (a Content Security Policy's `connect-src`, say) needs both.
956
+
957
+ "Beside `endpoint`" means the `/suggest` at the end of the endpoint's path is
958
+ replaced, keeping its origin, any path prefix and query
959
+ (`https://search.example.com/v1/suggest` → `https://search.example.com/v1/telemetry/events`).
960
+ When `endpoint` does not end in `/suggest` and one of the other options is not
961
+ set, that request is not sent:
962
+
963
+ - **Telemetry:** no events are sent.
964
+ - **Starting state:** it is asked for with an ordinary suggestion request (empty query) instead.
965
+ - **Location search:** the field takes typed text only.
966
+
967
+ ```ts
968
+ apiConfig: APIConfig = {
969
+ endpoint: "https://search.example.com/v1/complete",
970
+ // Needed because the endpoint above does not end in /suggest:
971
+ telemetryEndpoint: "https://search.example.com/v1/events",
972
+ startingStateEndpoint: "https://search.example.com/v1/start",
973
+ locationEndpoint: "https://search.example.com/v1/places",
974
+ };
975
+ ```
976
+
977
+ ```html
978
+ <ai-autocomplete [apiConfig]="apiConfig"></ai-autocomplete>
979
+ ```
980
+
981
+ The suggestion, location search and telemetry requests carry the same
982
+ headers: `Content-Type: application/json`, your `apiConfig.headers`,
983
+ `X-App-Identifier` when `appIdentifier` is set, and an `Authorization` header
984
+ from your API key or access token. The starting-state GET carries none of
985
+ them (no custom headers and no `Authorization`), so it can be served from a
986
+ cache; as a plain GET it still sends the page's cookies to a same-origin
987
+ endpoint. With your own
988
+ endpoint, the SDK opens no connection to the hosted service's hosts, including
989
+ the image CDN it otherwise warms up; images load from whatever URLs your
990
+ responses carry.
991
+
992
+ What each request sends and expects:
993
+
994
+ - **Suggestions:** the request body is `AutocompleteRequest` and the response
995
+ `AutocompleteResponse`, both exported as types by
996
+ `@magicx-eng/ai-autocomplete-vanilla`. The response's optional `custom_fields`
997
+ block is described in [The catalog report](#the-catalog-report-customfields).
998
+ - **Starting state:** the response is the same `AutocompleteResponse`; see
999
+ [Starting state](#starting-state). `{language}` is the lowercase primary
1000
+ language subtag (`es` for `es-MX`), or `zh-TW` for Traditional Chinese; the
1001
+ segment is left off when the language tag has no usable subtag.
1002
+ - **Location search:** the body is `{ query, session_token, language }` and the
1003
+ response `{ places: [{ id, name, secondary? }] }` (the `LocationPlace` type).
1004
+ A 404 turns the search off for the rest of the session; see
1005
+ [Location search](#location-search).
1006
+ - **Telemetry:** a fire-and-forget body of `source`, `session_id`, `type`, `at`
1007
+ and `query_data`, plus `visitor_id`, `search_id`, `request_id` and
1008
+ `language` when known. The response is ignored.