@magicx-eng/ai-autocomplete-angular 0.46.0 → 0.47.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 +78 -543
- package/REFERENCE.md +610 -0
- package/esm2020/lib/ai-autocomplete/ai-autocomplete.component.mjs +22 -5
- package/esm2020/lib/ai-autocomplete-dropdown/ai-autocomplete-dropdown.component.mjs +36 -8
- package/esm2020/lib/controller/ai-autocomplete.controller.mjs +47 -4
- package/esm2020/lib/internal/date-grid/date-grid.component.mjs +3 -3
- package/esm2020/lib/internal/location-field/location-field.component.mjs +370 -0
- package/esm2020/lib/internal/product-strip/product-strip.component.mjs +3 -3
- package/esm2020/lib/internal/submit-button/submit-button.component.mjs +7 -3
- package/esm2020/lib/internal/suggestion-grid/suggestion-grid.component.mjs +7 -3
- package/esm2020/lib/internal/suggestion-item/suggestion-item.component.mjs +22 -6
- package/esm2020/lib/shared/types.mjs +1 -1
- package/esm2020/public-api.mjs +6 -2
- package/fesm2015/magicx-eng-ai-autocomplete-angular.mjs +518 -33
- package/fesm2015/magicx-eng-ai-autocomplete-angular.mjs.map +1 -1
- package/fesm2020/magicx-eng-ai-autocomplete-angular.mjs +509 -28
- package/fesm2020/magicx-eng-ai-autocomplete-angular.mjs.map +1 -1
- package/lib/ai-autocomplete/ai-autocomplete.component.d.ts +9 -1
- package/lib/ai-autocomplete/ai-autocomplete.component.d.ts.map +1 -1
- package/lib/ai-autocomplete-dropdown/ai-autocomplete-dropdown.component.d.ts +13 -1
- package/lib/ai-autocomplete-dropdown/ai-autocomplete-dropdown.component.d.ts.map +1 -1
- package/lib/controller/ai-autocomplete.controller.d.ts +25 -3
- package/lib/controller/ai-autocomplete.controller.d.ts.map +1 -1
- package/lib/internal/location-field/location-field.component.d.ts +98 -0
- package/lib/internal/location-field/location-field.component.d.ts.map +1 -0
- package/lib/internal/submit-button/submit-button.component.d.ts +3 -1
- package/lib/internal/submit-button/submit-button.component.d.ts.map +1 -1
- package/lib/internal/suggestion-grid/suggestion-grid.component.d.ts +3 -1
- package/lib/internal/suggestion-grid/suggestion-grid.component.d.ts.map +1 -1
- package/lib/internal/suggestion-item/suggestion-item.component.d.ts +8 -2
- package/lib/internal/suggestion-item/suggestion-item.component.d.ts.map +1 -1
- package/lib/shared/types.d.ts +19 -1
- package/lib/shared/types.d.ts.map +1 -1
- package/package.json +5 -2
- package/public-api.d.ts +4 -2
- package/public-api.d.ts.map +1 -1
package/REFERENCE.md
ADDED
|
@@ -0,0 +1,610 @@
|
|
|
1
|
+
# @magicx-eng/ai-autocomplete-angular reference
|
|
2
|
+
|
|
3
|
+
Longer guides that do not fit in the [README](https://unpkg.com/@magicx-eng/ai-autocomplete-angular/README.md) on the npm page. This file ships in the package, at `node_modules/@magicx-eng/ai-autocomplete-angular/REFERENCE.md`.
|
|
4
|
+
|
|
5
|
+
- [Product strip](#product-strip)
|
|
6
|
+
- [Datepicker](#datepicker)
|
|
7
|
+
- [Time picker](#time-picker)
|
|
8
|
+
- [Multiple selections](#multiple-selections)
|
|
9
|
+
- [Location search](#location-search)
|
|
10
|
+
- [CSS variables](#css-variables)
|
|
11
|
+
- [Server-side rendering](#server-side-rendering)
|
|
12
|
+
|
|
13
|
+
## Product strip
|
|
14
|
+
|
|
15
|
+
The dropdown renders a horizontal row of product cards below the options grid
|
|
16
|
+
whenever it has products to show. By default those are the items the
|
|
17
|
+
`/suggest` response itself reports as matching the query. No configuration,
|
|
18
|
+
no extra request: the cards land in the same state emission as the
|
|
19
|
+
suggestions, so what the strip shows and what the pills offer always describe
|
|
20
|
+
the same narrowing.
|
|
21
|
+
|
|
22
|
+
```html
|
|
23
|
+
<ai-autocomplete
|
|
24
|
+
[apiConfig]="apiConfig"
|
|
25
|
+
(productSelect)="openProduct($event)"
|
|
26
|
+
(submitted)="onSubmit($event)"
|
|
27
|
+
></ai-autocomplete>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Each server item becomes a `Product` with `id` (the item's stable id), `title`,
|
|
31
|
+
`price` (the item's lowest price, verbatim as the catalog spells it; the
|
|
32
|
+
currency is yours to add), `compareAtPrice` (the price before a markdown, on a
|
|
33
|
+
discounted item only, struck through beside the price), `vendor`, `imageUrl`, and a `url`: the item's own
|
|
34
|
+
`item_url` when the uploaded catalog named one (absolute or root-relative;
|
|
35
|
+
anything else is ignored), else a **relative** `/products/{handle}` (the right
|
|
36
|
+
link for a Shopify widget running on the storefront itself), opened on the
|
|
37
|
+
variant the query chose (`?variant=…`, e.g. the blue one for "blue shoes") when
|
|
38
|
+
there is one, whose price and image the card then shows. `available` is carried
|
|
39
|
+
over when the server reports it. An item with
|
|
40
|
+
neither gets no `url`: its card is still activatable and still emits
|
|
41
|
+
`(productSelect)`, it just has nothing for cmd-click to open. `productFromMatchedItem` / `productsFromCustomFields` are
|
|
42
|
+
exported for a hand-rolled strip that wants the same mapping.
|
|
43
|
+
|
|
44
|
+
Bind `[showProducts]="false"` to render no strip at all. The catalog report
|
|
45
|
+
(below) stays readable either way.
|
|
46
|
+
|
|
47
|
+
`[productsLayout]="'list'"` stacks the same cards as full-width rows (thumbnail
|
|
48
|
+
on the left, title, vendor and price on the right) for results that read as
|
|
49
|
+
a list (courses, listings, documents) rather than products on a shelf. The
|
|
50
|
+
column scrolls vertically inside `--aia-product-list-max-height` (320px by
|
|
51
|
+
default); `--aia-product-list-media-size` (44px) sizes the thumbnail and
|
|
52
|
+
`--aia-product-list-gap` (2px) the space between rows. `"row"`, the default,
|
|
53
|
+
is the horizontal strip. Changing the binding re-lays the strip out at once, and
|
|
54
|
+
`<ai-autocomplete-dropdown>` takes the same input in Tier 2.
|
|
55
|
+
|
|
56
|
+
**Product image fallback.** A product's image takes priority when its
|
|
57
|
+
`imageUrl` loads successfully. A missing or blank URL, or an image load error,
|
|
58
|
+
uses `productImageFallback`: `"image"` (the default) shows the existing
|
|
59
|
+
placeholder pictogram; `"initial"` shows the first character of the trimmed,
|
|
60
|
+
uppercased title. This is a Unicode grapheme (so a combined character or emoji
|
|
61
|
+
stays together), with a Unicode code point fallback in older browsers. An
|
|
62
|
+
empty or whitespace-only title shows `?`. The fallback works in both row and
|
|
63
|
+
list layouts. Initial tiles are decorative (`aria-hidden="true"`); the card's
|
|
64
|
+
visible title supplies its text.
|
|
65
|
+
|
|
66
|
+
**Sold out.** A product with `available: false` shows a "Sold out" badge over
|
|
67
|
+
the top-left of its image (in the list layout, a smaller banner across the
|
|
68
|
+
bottom of the thumbnail) and its image is desaturated; the card stays
|
|
69
|
+
selectable and keeps its link. Absent or `true` shows no
|
|
70
|
+
badge, so leave `available` out when you don't know. The badge is part of the
|
|
71
|
+
card's text, so screen readers announce it. Theme it with
|
|
72
|
+
`--aia-product-badge-bg`, `--aia-product-badge-color`,
|
|
73
|
+
`--aia-product-badge-font-size` and `--aia-product-badge-inset`, and the list
|
|
74
|
+
banner with `--aia-product-badge-list-bg`, `--aia-product-badge-list-color` and
|
|
75
|
+
`--aia-product-badge-list-font-size`.
|
|
76
|
+
|
|
77
|
+
Bind `productImageFallback` on `<ai-autocomplete>` in Tier 1 or directly
|
|
78
|
+
on `<ai-autocomplete-dropdown>` in Tier 2:
|
|
79
|
+
|
|
80
|
+
```html
|
|
81
|
+
<!-- Tier 1 -->
|
|
82
|
+
<ai-autocomplete
|
|
83
|
+
[apiConfig]="apiConfig"
|
|
84
|
+
[productImageFallback]="'initial'"
|
|
85
|
+
(submitted)="onSubmit($event)"
|
|
86
|
+
></ai-autocomplete>
|
|
87
|
+
|
|
88
|
+
<!-- Tier 2 -->
|
|
89
|
+
<ai-autocomplete-dropdown
|
|
90
|
+
[controller]="ac"
|
|
91
|
+
[productImageFallback]="'initial'"
|
|
92
|
+
mode="auto"
|
|
93
|
+
></ai-autocomplete-dropdown>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Style the initial tile itself with `[data-aia-product-initial]`. For
|
|
97
|
+
example, wrap the widget in an element with `id="catalog-search"` and add this
|
|
98
|
+
rule to your stylesheet (the global stylesheet in Angular). The existing
|
|
99
|
+
`--aia-product-media-bg` variable sets the background; `color`, `font-size`
|
|
100
|
+
and `border-radius` style the initial without additional SDK options.
|
|
101
|
+
|
|
102
|
+
```css
|
|
103
|
+
#catalog-search [data-aia-product-initial] {
|
|
104
|
+
--aia-product-media-bg: #eef2ff;
|
|
105
|
+
color: #4338ca;
|
|
106
|
+
font-size: 22px;
|
|
107
|
+
border-radius: 12px;
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### The catalog report (`customFields$`)
|
|
112
|
+
|
|
113
|
+
Every response that read the catalog also says what it did with the query. The
|
|
114
|
+
controller exposes it as `customFields$` (and on `state$`), and it rides on
|
|
115
|
+
`AutocompleteResult` as `custom_fields`, so `(resultChange)` / `onResult`
|
|
116
|
+
carry it too:
|
|
117
|
+
|
|
118
|
+
```html
|
|
119
|
+
<ai-autocomplete (resultChange)="report = $event.custom_fields ?? null"></ai-autocomplete>
|
|
120
|
+
|
|
121
|
+
<p *ngIf="report">{{ report.items.total }} results</p>
|
|
122
|
+
<!-- e.g. { parameter: "Color", value: "Chartreuse", op: "eq" }: the shopper asked
|
|
123
|
+
for a colour no item carries, so the results ignore it. Say so. -->
|
|
124
|
+
<p *ngIf="report?.dropped_filters?.length">
|
|
125
|
+
No match for
|
|
126
|
+
<ng-container *ngFor="let filter of report.dropped_filters; let last = last">
|
|
127
|
+
{{ filter.value }}<ng-container *ngIf="!last">, </ng-container>
|
|
128
|
+
</ng-container>
|
|
129
|
+
</p>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
- `applied_filters` / `dropped_filters`: the constraints the server read out
|
|
133
|
+
of the query as `{ parameter, value, op }` (`op` is one of `eq`, `ne`, `lt`,
|
|
134
|
+
`lte`, `gt`, `gte`), split into the ones the catalog answered and the ones it
|
|
135
|
+
could not (a parameter it does not have, a bound that is not a number, a
|
|
136
|
+
value no item carries). The items answer the applied set, so the dropped
|
|
137
|
+
list is what tells "87 black t-shirts" from "no black item, so here are
|
|
138
|
+
t-shirts". Both are always arrays.
|
|
139
|
+
- `items.total`: how many items the applied filters left standing. It also
|
|
140
|
+
moves with the query's own words, so it drops as a typed word starts
|
|
141
|
+
matching a title. `items.matched` is the list the strip renders, capped by
|
|
142
|
+
the server; it is empty (with a non-zero `total`) when nothing narrowed the
|
|
143
|
+
catalog, where listing arbitrary items as matches would mislead.
|
|
144
|
+
- `null` (no `custom_fields` key on the result) means the response carried no
|
|
145
|
+
report: no catalog was read for it (a product with no catalog, the starting
|
|
146
|
+
state, a response with no option-bearing parameter to offer). That is "no
|
|
147
|
+
news", not an empty catalog. The strip clears on such a response rather than
|
|
148
|
+
keeping an older query's items.
|
|
149
|
+
|
|
150
|
+
### Change product cards before display
|
|
151
|
+
|
|
152
|
+
- `mapProducts(products, items)` synchronously returns the cards to show.
|
|
153
|
+
- The SDK calls it once per response with its default cards and their matched items in the same order.
|
|
154
|
+
- The returned array becomes the product state and the displayed strip.
|
|
155
|
+
- A thrown error or a non-array result keeps the default cards. A thrown error warns once per instance.
|
|
156
|
+
- `refreshProducts()` maps the current items again without a request. Call it when your own data arrives.
|
|
157
|
+
- Both APIs leave a custom `products` integration unchanged.
|
|
158
|
+
|
|
159
|
+
- Pass `mapProducts` to `new AIAutocompleteController({ mapProducts })` and call `controller.refreshProducts()`.
|
|
160
|
+
- Bind `[mapProducts]="mapProducts"` on `<ai-autocomplete>` and call `refreshProducts()` on the component.
|
|
161
|
+
- Changing the callback through `controller.update({ mapProducts })` or the input maps the current items again.
|
|
162
|
+
- Define the callback as a stable component field.
|
|
163
|
+
|
|
164
|
+
```ts
|
|
165
|
+
mapProducts = (products: Product[], items: MatchedItem[]): Product[] =>
|
|
166
|
+
products.map((product, index) => ({
|
|
167
|
+
...product,
|
|
168
|
+
price: this.shopperPrices[items[index].source_id] ?? "",
|
|
169
|
+
}));
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Your own product search (`products`)
|
|
173
|
+
|
|
174
|
+
To source the cards from your own search instead (a platform with its own
|
|
175
|
+
endpoint and response shape), bind `[products]`. The SDK owns the UI; you own
|
|
176
|
+
only the fetching and the mapping. The server's items are then not rendered
|
|
177
|
+
(they stay readable on `customFields$`).
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
import { Component } from "@angular/core";
|
|
181
|
+
import type { Product, ProductsConfig } from "@magicx-eng/ai-autocomplete-angular";
|
|
182
|
+
|
|
183
|
+
@Component({
|
|
184
|
+
template: `<ai-autocomplete
|
|
185
|
+
[apiConfig]="apiConfig"
|
|
186
|
+
[products]="products"
|
|
187
|
+
(productSelect)="openProduct($event)"
|
|
188
|
+
(submitted)="onSubmit($event)"
|
|
189
|
+
></ai-autocomplete>`,
|
|
190
|
+
})
|
|
191
|
+
export class SearchComponent {
|
|
192
|
+
// A component field, not an inline object literal: a new reference on each
|
|
193
|
+
// change-detection pass reads as a swapped integration and clears the
|
|
194
|
+
// current cards (the same rule `apiConfig` and `optionOverrides` follow).
|
|
195
|
+
products: ProductsConfig = {
|
|
196
|
+
// You own the request entirely: auth headers, GraphQL body, locale
|
|
197
|
+
// prefixes. Honour the signal: the SDK aborts it as soon as a newer query
|
|
198
|
+
// supersedes this one.
|
|
199
|
+
fetch: (query, signal) =>
|
|
200
|
+
fetch(`/api/products?q=${encodeURIComponent(query)}`, { signal }).then((r) => r.json()),
|
|
201
|
+
|
|
202
|
+
// Pure mapping, kept out of `fetch` so you can unit-test it without a
|
|
203
|
+
// network.
|
|
204
|
+
transform: (raw): Product[] =>
|
|
205
|
+
(raw as ApiResponse).items.map((item) => ({
|
|
206
|
+
id: item.id,
|
|
207
|
+
title: item.title,
|
|
208
|
+
url: item.url,
|
|
209
|
+
imageUrl: item.image?.src ?? null, // null uses the configured productImageFallback
|
|
210
|
+
price: formatMoney(item.price), // you know the currency
|
|
211
|
+
vendor: item.brand,
|
|
212
|
+
})),
|
|
213
|
+
|
|
214
|
+
limit: 8, // applied by the SDK, after transform
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
// Selection emits an event. The SDK never navigates.
|
|
218
|
+
openProduct(product: Product): void {
|
|
219
|
+
if (product.url) this.router.navigateByUrl(product.url);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
`Product` is exactly seven fields; only `id` and `title` are required:
|
|
225
|
+
|
|
226
|
+
```ts
|
|
227
|
+
type Product = {
|
|
228
|
+
id: string;
|
|
229
|
+
title: string;
|
|
230
|
+
url?: string; // absent = a card with no link (still activatable)
|
|
231
|
+
imageUrl?: string | null;
|
|
232
|
+
price?: string;
|
|
233
|
+
compareAtPrice?: string; // the price before a markdown; struck through beside price
|
|
234
|
+
vendor?: string;
|
|
235
|
+
available?: boolean; // false shows a "Sold out" badge
|
|
236
|
+
};
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
**What the SDK guarantees**
|
|
240
|
+
|
|
241
|
+
- **One fetch cadence.** The product search rides the same debounce, the same
|
|
242
|
+
`AbortController` and the same version guard as `/suggest`, so there is no
|
|
243
|
+
second timer to drift out of step.
|
|
244
|
+
- **Empty queries never reach you.** On mount and after `reset()` the strip
|
|
245
|
+
clears.
|
|
246
|
+
- **Out-of-order responses are dropped.** A slow response for an older query is
|
|
247
|
+
never rendered over a newer one.
|
|
248
|
+
- **Failure is silent.** A rejected `fetch` or a throwing `transform` clears the
|
|
249
|
+
strip, logs once, and leaves the suggestions half untouched: no `error`
|
|
250
|
+
state, no `errored` output, no effect on `isLoading$`.
|
|
251
|
+
- **The two halves are independent.** The panel opens if *either* has content,
|
|
252
|
+
so products keep it open when option filtering empties the option list.
|
|
253
|
+
`dropdownTrigger` (`manual` / `hidden`) still gates the panel as before.
|
|
254
|
+
|
|
255
|
+
**Add to cart.** Bind `[onProductAddToCart]` and every card that isn't sold
|
|
256
|
+
out (`available: false`) shows a round cart button over the bottom-right corner
|
|
257
|
+
of its image (in the list layout, at the right end of the row). Leave it
|
|
258
|
+
unbound (or bind `undefined`) and no card has one; binding or unbinding it later
|
|
259
|
+
adds or removes the buttons. The SDK never touches a cart: pressing the button
|
|
260
|
+
calls your function with the card's `Product`, and does not emit
|
|
261
|
+
`(productSelect)`, navigate or close the panel.
|
|
262
|
+
|
|
263
|
+
```ts
|
|
264
|
+
// A field, not a method reference, so `this` stays bound.
|
|
265
|
+
addToCart = (product: Product) => this.cart.add(product.id); // may return a promise
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
```html
|
|
269
|
+
<ai-autocomplete [apiConfig]="apiConfig" [onProductAddToCart]="addToCart"></ai-autocomplete>
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
Return a promise (or any thenable — convert an `Observable` with
|
|
273
|
+
`firstValueFrom`) to have the button show progress. While it is pending the
|
|
274
|
+
button carries `data-aia-cart-state="adding"` (and `aria-busy="true"`), spins
|
|
275
|
+
and ignores further presses; once it resolves the cart turns into a check
|
|
276
|
+
(`data-aia-cart-state="added"`) and stays one until the card's product changes
|
|
277
|
+
(a price-only change keeps it). Pressing it again adds another unit, back
|
|
278
|
+
through "adding" to "added". A rejection puts the button back at rest — show your own error. A function that returns nothing goes
|
|
279
|
+
straight to "added". The button is labelled "Add to cart: {title}" in the
|
|
280
|
+
widget language, reachable by Tab and pressed with Enter or Space. Theme it
|
|
281
|
+
with `--aia-product-cart-size` (28px), `--aia-product-cart-bg` and
|
|
282
|
+
`--aia-product-cart-color`; its focus ring uses `--aia-product-focus-ring`.
|
|
283
|
+
The button is a `[data-aia-product-cart]` element, and a card that has one
|
|
284
|
+
carries `data-aia-product-has-cart`.
|
|
285
|
+
|
|
286
|
+
**Selection and links.** Cards are real `<a href>` elements, so cmd/ctrl-click,
|
|
287
|
+
middle-click and "copy link address" behave natively. A plain left click is
|
|
288
|
+
intercepted (`preventDefault`) and emits `(productSelect)` instead.
|
|
289
|
+
|
|
290
|
+
`product.url` is used verbatim: the SDK trusts your `transform` output and
|
|
291
|
+
does not sanitise it, so validate the URL there if the platform response isn't
|
|
292
|
+
fully under your control. (Angular additionally runs its own `href`
|
|
293
|
+
sanitiser, so unrecognised schemes like `myapp://…` are rewritten to
|
|
294
|
+
`unsafe:…` in that package only.)
|
|
295
|
+
|
|
296
|
+
**Accessibility.** The strip is a `role="group"` labelled "Best match"; each card
|
|
297
|
+
is a `role="option"` in the tab order, activated with Enter or Space, with a
|
|
298
|
+
visible focus ring. Tabbing into the strip does not close the panel. The row
|
|
299
|
+
scrolls horizontally by trackpad, wheel, touch and keyboard; the page never
|
|
300
|
+
scrolls sideways and the scrollbar chrome is hidden in all engines.
|
|
301
|
+
|
|
302
|
+
Swapping `[products]` for a different config clears the current cards; the
|
|
303
|
+
strip repopulates on the *next* `/suggest` request rather than immediately,
|
|
304
|
+
since the product search rides that one scheduler. Binding it back to
|
|
305
|
+
`undefined` hands the strip back to the server's items at once, and toggling
|
|
306
|
+
`[showProducts]` empties or restores it at once.
|
|
307
|
+
|
|
308
|
+
Tier 2 gets the same thing: pass `showProducts` / `products` /
|
|
309
|
+
`onProductSelect` to the `AIAutocompleteController` and
|
|
310
|
+
`<ai-autocomplete-dropdown>` renders the strip. Tier 3 consumers subscribe to
|
|
311
|
+
`products$` (and `customFields$`) and call `controller.selectProduct(product)`
|
|
312
|
+
from their own cards.
|
|
313
|
+
|
|
314
|
+
## Datepicker
|
|
315
|
+
|
|
316
|
+
When the next parameter is a date, the dropdown shows a calendar instead of a
|
|
317
|
+
list of options. Which parameters are dates is the server's call: one whose
|
|
318
|
+
`type` is `date` gets a calendar, and one without a date type keeps its option
|
|
319
|
+
list, however date-like its name or options look.
|
|
320
|
+
|
|
321
|
+
Nothing is required to switch it on: a date parameter renders this way
|
|
322
|
+
automatically, and every other parameter is unaffected. Tier 1 and Tier 2
|
|
323
|
+
render the calendar for you; in Tier 3 the same data reaches `dropdown$` so you
|
|
324
|
+
can render your own (see [Tier 3](README.md#tier-3-headless)).
|
|
325
|
+
|
|
326
|
+
**What the user can do**
|
|
327
|
+
|
|
328
|
+
| Input | Result |
|
|
329
|
+
|---|---|
|
|
330
|
+
| Click a day | Commits that date |
|
|
331
|
+
| <kbd>↓</kbd> | Moves into the calendar, starting on today |
|
|
332
|
+
| <kbd>←</kbd> / <kbd>→</kbd> | Previous / next day, crossing week boundaries |
|
|
333
|
+
| <kbd>↑</kbd> / <kbd>↓</kbd> | Previous / next week. Past either end of the month, focus returns to the input |
|
|
334
|
+
| <kbd>Enter</kbd> | Commits the highlighted day |
|
|
335
|
+
| Month arrows | Page the calendar. Paging never commits anything |
|
|
336
|
+
| <kbd>→</kbd> at the end of the input | Skips the parameter, same as any other pill |
|
|
337
|
+
|
|
338
|
+
**The committed value** is written the way a person would write it, always in
|
|
339
|
+
English regardless of the visitor's locale, so the value you receive has one
|
|
340
|
+
vocabulary everywhere:
|
|
341
|
+
|
|
342
|
+
- a date inside the next week (today included) commits as its weekday name:
|
|
343
|
+
`Tuesday`. Like the sentence it sits in, that name is relative: read later,
|
|
344
|
+
it means the next such day;
|
|
345
|
+
- one further out in the current year as `MONTH DAY`: `March 23`;
|
|
346
|
+
- one in another year as `MONTH DAY YEAR`: `March 23 2027`.
|
|
347
|
+
|
|
348
|
+
It arrives as an ordinary completed parameter: bold in the input,
|
|
349
|
+
and present in `completed_params` on submit like any other answer.
|
|
350
|
+
|
|
351
|
+
**Re-editing** a committed date re-opens the calendar on the month the committed
|
|
352
|
+
text names, with that day marked, so changing an answer takes one click. For a
|
|
353
|
+
weekday name that reading is relative, so once the day it named has gone by,
|
|
354
|
+
re-editing marks the next such day rather than the one originally picked: the
|
|
355
|
+
calendar shows what the sentence says today, which is also what gets submitted.
|
|
356
|
+
|
|
357
|
+
**Reading the value back.** The date arrives as text, so if you need a `Date`
|
|
358
|
+
object, `parseDate` is exported for it:
|
|
359
|
+
|
|
360
|
+
```ts
|
|
361
|
+
import { parseDate } from "@magicx-eng/ai-autocomplete-angular";
|
|
362
|
+
|
|
363
|
+
// Reads all three committed shapes: a weekday name is the one date it can
|
|
364
|
+
// mean in the next seven days, and a yearless month-day is the current year.
|
|
365
|
+
const due = parseDate("March 23"); // Date, or null if the text isn't one of ours
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
`parseLooseDate` is exported too, for the looser shapes a person types into a
|
|
369
|
+
query: it reads `september 5th`, `5th September`, `Sept 5` and `2026-09-05`,
|
|
370
|
+
and answers `null` for anything ambiguous rather than guessing.
|
|
371
|
+
|
|
372
|
+
**Dates the user writes themselves.** When someone types a date into their query
|
|
373
|
+
("fly to vegas on september 5th"), the parameter it answers is recognised in
|
|
374
|
+
place and the date becomes tappable. Tapping it opens the calendar on that
|
|
375
|
+
month with the day already marked, so confirming or changing it takes one tap,
|
|
376
|
+
and the picked date replaces their words with the canonical form.
|
|
377
|
+
|
|
378
|
+
The written date is read where it can be: `september 5th`, `5th September`,
|
|
379
|
+
`Sept 5`, `September 5, 2026` and `2026-09-05` all resolve, in any of those
|
|
380
|
+
orders and with or without the year (a date with no year means its next
|
|
381
|
+
occurrence). Two cases deliberately don't pre-select: a numeric date like
|
|
382
|
+
`09/05`, which is September 5th in the US and May 9th elsewhere with nothing to
|
|
383
|
+
say which, and phrases like `next friday`. Those still open the calendar, just
|
|
384
|
+
on the current month with nothing marked, so the user picks rather than being
|
|
385
|
+
shown a guess that might be wrong.
|
|
386
|
+
|
|
387
|
+
**Date ranges.** A parameter whose `type` is `date_range` is answered by the
|
|
388
|
+
same calendar in two clicks: the first sets the start, the second the end, and the pair
|
|
389
|
+
commits as one answer. The days between them band as the user moves across the
|
|
390
|
+
calendar, so the span being chosen is visible before it is committed. Paging the
|
|
391
|
+
month between the two clicks is expected (that is how a span crosses months),
|
|
392
|
+
and <kbd>Esc</kbd> drops the start and lets them begin again. Clicking the end
|
|
393
|
+
before the start is fine; the two are ordered on the way in.
|
|
394
|
+
|
|
395
|
+
It commits as one parameter, written as a span,
|
|
396
|
+
`September 11 - October 13`, with the year on whichever end needs it, and both
|
|
397
|
+
ends are also recorded on the completed parameter's `metadata` as `YYYY-MM-DD`,
|
|
398
|
+
under the `DATE_RANGE_META_START` / `DATE_RANGE_META_END` keys this package
|
|
399
|
+
exports (`aiaDateRangeStart` / `aiaDateRangeEnd`), so you never have to parse
|
|
400
|
+
the prose. Re-editing one re-opens the calendar with both ends marked.
|
|
401
|
+
|
|
402
|
+
**Typing** while the calendar is open does not filter it. The text is treated as
|
|
403
|
+
a new query, so suggestions refresh as the user types, which helps when someone
|
|
404
|
+
would rather describe what they want than pick a day.
|
|
405
|
+
|
|
406
|
+
## Time picker
|
|
407
|
+
|
|
408
|
+
When the next parameter is a time, the dropdown shows a time wheel instead of a
|
|
409
|
+
list of options. As with dates, which parameters are times is the server's call:
|
|
410
|
+
one whose `type` is `time` gets the wheel, and one without it keeps its option
|
|
411
|
+
list, however time-like its options look.
|
|
412
|
+
|
|
413
|
+
Nothing is required to switch it on. The options the server still sends for a
|
|
414
|
+
time parameter are never shown, but they choose where the wheel opens: on the
|
|
415
|
+
middle of the times suggested (`6 PM`, `7 PM`, `8 PM` opens on 7:00 PM), or on
|
|
416
|
+
the next whole hour when there are none.
|
|
417
|
+
|
|
418
|
+
**What the user can do**
|
|
419
|
+
|
|
420
|
+
| Input | Result |
|
|
421
|
+
|---|---|
|
|
422
|
+
| Scroll or tap a wheel | Turns that wheel; the time on the top rows is the time. Commits nothing |
|
|
423
|
+
| <kbd>↓</kbd> / <kbd>↑</kbd> in the input | Moves the time 5 minutes later / earlier |
|
|
424
|
+
| <kbd>Enter</kbd> | Commits the time — once the wheel has been moved. Until then it is only a suggestion, and Enter submits as usual |
|
|
425
|
+
| Done | Commits the time |
|
|
426
|
+
| <kbd>Esc</kbd> | Puts a moved wheel back on its suggested time |
|
|
427
|
+
| <kbd>→</kbd> at the end of the input | Skips the parameter, same as any other pill |
|
|
428
|
+
|
|
429
|
+
**The committed value** is written the way a person would write it, always in
|
|
430
|
+
English: `7:30 PM`, `12:05 AM`. It arrives as an ordinary completed parameter
|
|
431
|
+
(bold in the input, in `completed_params` on submit) with the server's lead-in
|
|
432
|
+
before it when there is one (`at 7:30 PM`). The exact time is also recorded on
|
|
433
|
+
the parameter's `metadata` as 24-hour `HH:MM` under the `TIME_META_KEY` key
|
|
434
|
+
(`aiaTime`), so you never have to parse the prose:
|
|
435
|
+
|
|
436
|
+
```ts
|
|
437
|
+
import { parseTime, TIME_META_KEY } from "@magicx-eng/ai-autocomplete-angular";
|
|
438
|
+
|
|
439
|
+
const time = param.metadata?.[TIME_META_KEY]; // "19:30"
|
|
440
|
+
const minutes = parseTime(param.text); // 1170 — minutes since midnight, or null
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
**Re-editing** a committed time re-opens the wheel on it.
|
|
444
|
+
|
|
445
|
+
**Typing** while the wheel is open does not filter anything. As with the
|
|
446
|
+
calendar, the text is treated as a new query.
|
|
447
|
+
|
|
448
|
+
## Multiple selections
|
|
449
|
+
|
|
450
|
+
- A suggestion with `type: { kind: "multi_select" }` shows checkbox options and a Done button.
|
|
451
|
+
- The option list shows three rows and scrolls the rest, on every screen size, so Done is always in view right under it.
|
|
452
|
+
- A click or tap on a row's checkbox (or just beside it) ticks the row and waits for Done. A click or tap anywhere else on the row (its text, or the space after it) answers right away with that option, together with anything already ticked. Space and Enter always tick. In code: `selectOption(option, { commit: true })`.
|
|
453
|
+
- Select rows to toggle values. Typing filters the options and keeps the current picks.
|
|
454
|
+
- Done joins the picks in selection order with the UI language's word for "and".
|
|
455
|
+
- Each value has its own `completed_params` entry. The input shows one chip for the group.
|
|
456
|
+
- Remove the group chip to change the answer. Group chips do not open for editing.
|
|
457
|
+
- Done without picks skips the question. Typing a phrase with no matching options closes the question and keeps that phrase.
|
|
458
|
+
- Space toggles the highlighted row when nothing is typed for the question. Enter commits the picks, or selects the highlighted row when no values are picked.
|
|
459
|
+
- Headless integrations can call `toggleMultiSelectOption(option)` and `commitMultiSelect()`.
|
|
460
|
+
- `multiSelectView.picked` contains the selected option texts. The view is null outside a multi_select question.
|
|
461
|
+
|
|
462
|
+
## Location search
|
|
463
|
+
|
|
464
|
+
A location parameter is answered one of two ways, depending on whether the
|
|
465
|
+
server sends options for it. As with dates, which parameters are
|
|
466
|
+
locations is the server's call: it marks them `type: { kind: "location" }`.
|
|
467
|
+
|
|
468
|
+
- **With options** (a catalog with a `city` field, say), it is an ordinary
|
|
469
|
+
option list. Nothing changes.
|
|
470
|
+
- **Without options**, the dropdown shows a search field instead. Typing in it
|
|
471
|
+
searches places through the MagicX server, which proxies a location provider,
|
|
472
|
+
and lists what it finds; any city, address or landmark can be picked.
|
|
473
|
+
|
|
474
|
+
Nothing is required to switch it on. The field searches
|
|
475
|
+
`…/locations/autocomplete`, next to your `/suggest` endpoint
|
|
476
|
+
(`/api/suggest` → `/api/locations/autocomplete`). If `apiConfig.endpoint`
|
|
477
|
+
points at a proxy with its own path, set `apiConfig.locationEndpoint` too.
|
|
478
|
+
The SDK calls that route directly; `/suggest` doesn't need to say anything
|
|
479
|
+
about it. If the route answers 404 (a server without it), the field takes
|
|
480
|
+
typed text for the rest of the session. Any other failure (401, 429, a
|
|
481
|
+
timeout) only costs that one search: Enter commits the typed text, and the
|
|
482
|
+
next phrase tries again.
|
|
483
|
+
|
|
484
|
+
**Turning the search off.** Set `[locationSearch]="false"` (or `locationSearch: false` in the controller config) to keep the field but take typed text
|
|
485
|
+
only — nothing the user types is sent for a lookup.
|
|
486
|
+
|
|
487
|
+
**Your own places.** An `optionOverrides` entry for the parameter takes
|
|
488
|
+
priority over the search: the parameter is answered from your list like any
|
|
489
|
+
other option list (a store's branches, say), and the search never runs.
|
|
490
|
+
|
|
491
|
+
**What the user can do**
|
|
492
|
+
|
|
493
|
+
| Input | Result |
|
|
494
|
+
|---|---|
|
|
495
|
+
| The pill coming up while the user is typing | Focus moves into the search field, so the place is typed straight into it |
|
|
496
|
+
| Typing in the field | Searches after a short pause (2 characters or more) |
|
|
497
|
+
| <kbd>↓</kbd> / <kbd>↑</kbd> | Moves through the places found |
|
|
498
|
+
| <kbd>Enter</kbd> or a tap on a place | Commits it. With nothing found, Enter commits the typed text as written. So does Enter pressed before the search answers (within the 250ms pause): nothing is highlighted yet |
|
|
499
|
+
| <kbd>Esc</kbd>, or <kbd>Backspace</kbd> in an empty field | Back to the input, the pill left open |
|
|
500
|
+
| <kbd>Tab</kbd> / <kbd>Shift</kbd>+<kbd>Tab</kbd> | On to the next control / back to the input, as for any field |
|
|
501
|
+
|
|
502
|
+
**The committed value** reads as the place and its region (`Seattle, WA`), with
|
|
503
|
+
the server's lead-in before it when there is one (`in Seattle, WA`). A picked
|
|
504
|
+
place also records the provider's place ID on the parameter's `metadata` under
|
|
505
|
+
`LOCATION_META_KEY` (`aiaPlace`); typed text records none:
|
|
506
|
+
|
|
507
|
+
```ts
|
|
508
|
+
import { LOCATION_META_KEY } from "@magicx-eng/ai-autocomplete-angular";
|
|
509
|
+
|
|
510
|
+
const place = param.metadata?.[LOCATION_META_KEY]; // { id: "ChIJ…" } | undefined
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
**Re-editing** a committed place re-opens the field on it, selected, so typing
|
|
514
|
+
replaces it.
|
|
515
|
+
|
|
516
|
+
---
|
|
517
|
+
|
|
518
|
+
## CSS variables
|
|
519
|
+
|
|
520
|
+
Override on the host element (via `class`). The variables are declared with `:where()` (zero specificity), so a value you set on the host always wins.
|
|
521
|
+
|
|
522
|
+
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.
|
|
523
|
+
|
|
524
|
+
```css
|
|
525
|
+
.my-search {
|
|
526
|
+
--aia-input-radius: 0;
|
|
527
|
+
--aia-written-text-font-weight: 500;
|
|
528
|
+
}
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
| Variable | Light | Dark | Description |
|
|
532
|
+
|---|---|---|---|
|
|
533
|
+
| `--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. |
|
|
534
|
+
| `--aia-pill-bg` | `#bdbdbd` | `#bdbdbd` | Pill background |
|
|
535
|
+
| `--aia-pill-color` | `#000000` | `#ffffff` | Pill text |
|
|
536
|
+
| `--aia-pill-font-size` | `19px` | `19px` | Pill font size |
|
|
537
|
+
| `--aia-option-bg` | `transparent` | `transparent` | Highlighted option background |
|
|
538
|
+
| `--aia-option-color` | `#000000` | `#ffffff` | Option text |
|
|
539
|
+
| `--aia-option-color-selected` | `#000000` | `#ffffff` | Highlighted option text |
|
|
540
|
+
| `--aia-option-font-size` | `19px` | `19px` | Option font size |
|
|
541
|
+
| `--aia-written-text-color` | `#000000` | `#ffffff` | Input text |
|
|
542
|
+
| `--aia-written-text-font-size` | `19px` | `19px` | Input text font size |
|
|
543
|
+
| `--aia-input-radius` | `10px` | `10px` | Full input corner radius. Set `0` for square corners. |
|
|
544
|
+
| `--aia-written-text-font-weight` | `300` | `300` | Written text weight in the full input. Completed chips keep their own typography. |
|
|
545
|
+
| `--aia-caret-color` | `--aia-written-text-color` | `--aia-written-text-color` | Editor caret color. Override independently of input text color. |
|
|
546
|
+
| `--aia-submit-bg` | `#000000` | `#ffffff` | Submit button background |
|
|
547
|
+
| `--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. |
|
|
548
|
+
| `--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. |
|
|
549
|
+
| `--aia-submit-color` | `#ffffff` | `#000000` | Submit button icon color |
|
|
550
|
+
| `--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. |
|
|
551
|
+
| `--aia-scrollbar-thumb` | `rgba(0, 0, 0, 0.3)` | `rgba(0, 0, 0, 0.3)` | No longer used: the option list hides its scrollbar in every browser. Kept so existing overrides don't break. |
|
|
552
|
+
| `--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. |
|
|
553
|
+
| `--aia-product-card-width` | `116px` | `116px` | Width of a product card in the strip. The media tile is square, so this also sets its height. |
|
|
554
|
+
| `--aia-product-gap` | `8px` | `8px` | Gap between product cards. |
|
|
555
|
+
| `--aia-product-bg` | `transparent` | `transparent` | Product card background. |
|
|
556
|
+
| `--aia-product-bg-active` | `--aia-option-bg` | `--aia-option-bg` | Product card background on hover. |
|
|
557
|
+
| `--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. |
|
|
558
|
+
| `--aia-scroll-arrow-color` | `--aia-option-color` | `--aia-option-color` | Chevron color of the arrow (`--aia-scroll-arrow-color-hover` on hover). |
|
|
559
|
+
| `--aia-placeholder-fade` | `120ms` | `120ms` | Fade-out of the outgoing placeholder phrase when the starting-state placeholder changes (the incoming one types itself in). |
|
|
560
|
+
| `--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. |
|
|
561
|
+
| `--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. |
|
|
562
|
+
| `--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. |
|
|
563
|
+
| `--aia-product-price-color` | `--aia-option-color-selected` | `--aia-option-color-selected` | Product price text. |
|
|
564
|
+
| `--aia-product-compare-at-color` | `currentColor` | `currentColor` | The struck price before a markdown. Defaults to the price's colour. |
|
|
565
|
+
| `--aia-product-compare-at-opacity` | `0.6` | `0.6` | How far the struck price is dimmed. |
|
|
566
|
+
| `--aia-product-vendor-color` | `--aia-option-color` | `--aia-option-color` | Product vendor line. |
|
|
567
|
+
| `--aia-product-focus-ring` | `--aia-option-color-selected` | `--aia-option-color-selected` | Focus ring drawn on a keyboard-focused card. |
|
|
568
|
+
| `--aia-products-label-color` | `--aia-option-color` | `--aia-option-color` | "Best match" section label. |
|
|
569
|
+
| `--aia-product-title-font-size` | `12px` | `12px` | Product title font size. |
|
|
570
|
+
| `--aia-product-price-font-size` | `11px` | `11px` | Product price font size. |
|
|
571
|
+
| `--aia-product-vendor-font-size` | `10px` | `10px` | Product vendor font size. |
|
|
572
|
+
| `--aia-products-label-font-size` | `11px` | `11px` | Section label font size. |
|
|
573
|
+
| `--aia-date-panel-width` | `312px` | `312px` | Max width of the whole dropdown panel while the calendar is up — the panel narrows to calendar size. |
|
|
574
|
+
| `--aia-date-cell-size` | `26px` | `26px` | Size of a day's square — the box that carries the highlight, the today ring and the selected fill. |
|
|
575
|
+
| `--aia-date-row-height` | `28px` | `28px` | Height of one week row. Lower it to fit a 6-week month in a shorter dropdown. |
|
|
576
|
+
| `--aia-date-row-min-height` | `20px` | `20px` | The shortest a week row may get when the dropdown is fitted to a short window and the weeks share what is left. Never applies above `--aia-date-row-height`. |
|
|
577
|
+
| `--aia-date-cell-font-size` | `13px` | `13px` | Day-number font size. |
|
|
578
|
+
| `--aia-date-month-font-size` | `14px` | `14px` | Font size of the "March 2026" header. |
|
|
579
|
+
| `--aia-date-weekday-font-size` | `11px` | `11px` | Font size of the S/M/T/W/T/F/S column letters. |
|
|
580
|
+
| `--aia-date-today-ring` | `--aia-option-color` | `--aia-option-color` | Outline drawn around today's date. |
|
|
581
|
+
| `--aia-date-selected-bg` | white at 12% | white at 12% | Fill behind the date a re-edited parameter already holds. |
|
|
582
|
+
| `--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`. |
|
|
583
|
+
| `--aia-time-panel-width` | `240px` | `240px` | Max width of the whole dropdown panel while the time wheel is up. |
|
|
584
|
+
| `--aia-time-font-size` | `15px` | `15px` | The time wheel's numbers and its `:` separator. |
|
|
585
|
+
| `--aia-time-band-bg` | white at 8% | white at 8% | The band behind the wheels' top rows — the chosen time. |
|
|
586
|
+
| `--aia-time-done-bg` | white at 10% | white at 10% | The time wheel's Done button. |
|
|
587
|
+
| `--aia-time-done-bg-hover` | white at 16% | white at 16% | The Done button on hover. |
|
|
588
|
+
| `--aia-time-done-color` | `--aia-option-color-selected` | `--aia-option-color-selected` | The Done button's text. |
|
|
589
|
+
| `--aia-location-field-bg` | `--aia-streak-rgb` at 6% (indigo) | `--aia-streak-rgb` at 6% (white) | The location search field. |
|
|
590
|
+
| `--aia-location-field-radius` | `10px` | `10px` | Corner radius of the location search field. |
|
|
591
|
+
| `--aia-location-font-size` | `15px` | `15px` | The location field's text and the place names. |
|
|
592
|
+
| `--aia-location-row-bg-highlighted` | `--aia-streak-rgb` at 8% (indigo) | `--aia-streak-rgb` at 8% (white) | The highlighted (or hovered) place. |
|
|
593
|
+
| `--aia-skeleton-bg` | `rgba(189, 189, 189, 0.083)` | `#1a1b1d` | Fill color for the loading skeleton bars and masked text in cached pills/options, and of the option and chip image tiles while their picture loads (unless `--aia-option-image-bg` / `--aia-chip-image-bg` are set). |
|
|
594
|
+
| `--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. |
|
|
595
|
+
| `--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. |
|
|
596
|
+
|
|
597
|
+
## Server-side rendering
|
|
598
|
+
|
|
599
|
+
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`:
|
|
600
|
+
|
|
601
|
+
```ts
|
|
602
|
+
import { Inject, PLATFORM_ID } from "@angular/core";
|
|
603
|
+
import { isPlatformBrowser } from "@angular/common";
|
|
604
|
+
|
|
605
|
+
constructor(@Inject(PLATFORM_ID) private platformId: object) {
|
|
606
|
+
if (isPlatformBrowser(platformId)) {
|
|
607
|
+
this.ac = new AIAutocompleteController({ ... });
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
```
|