@magicx-eng/ai-autocomplete-vanilla 0.34.0 → 0.35.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 +17 -2
- package/dist/index.d.mts +22 -3
- package/dist/index.d.ts +22 -3
- package/dist/index.js +58 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -202,7 +202,10 @@ Each server item becomes a `Product` with `id` (the item's stable id), `title`,
|
|
|
202
202
|
currency is yours to add), `vendor`, `imageUrl`, and a `url`: the item's own
|
|
203
203
|
`item_url` when the uploaded catalog named one (absolute or root-relative;
|
|
204
204
|
anything else is ignored), else a **relative** `/products/{handle}` — the right
|
|
205
|
-
link for a Shopify widget running on the storefront itself
|
|
205
|
+
link for a Shopify widget running on the storefront itself — opened on the
|
|
206
|
+
variant the query chose (`?variant=…`, e.g. the blue one for "blue shoes") when
|
|
207
|
+
there is one, whose price and image the card then shows. `available` is carried
|
|
208
|
+
over when the server reports it. An item with
|
|
206
209
|
neither gets no `url`: its card is still activatable and still emits
|
|
207
210
|
`onProductSelect`, it just has nothing for cmd-click to open. `productFromMatchedItem` / `productsFromCustomFields` are
|
|
208
211
|
exported for a hand-rolled strip that wants the same mapping.
|
|
@@ -229,6 +232,17 @@ empty or whitespace-only title shows `?`. The fallback works in both row and
|
|
|
229
232
|
list layouts. Initial tiles are decorative (`aria-hidden="true"`); the card's
|
|
230
233
|
visible title supplies its text.
|
|
231
234
|
|
|
235
|
+
**Sold out.** A product with `available: false` shows a "Sold out" badge over
|
|
236
|
+
the top-left of its image (in the list layout, a smaller banner across the
|
|
237
|
+
bottom of the thumbnail) and its image is desaturated; the card stays
|
|
238
|
+
selectable and keeps its link. Absent or `true` shows no
|
|
239
|
+
badge, so leave `available` out when you don't know. The badge is part of the
|
|
240
|
+
card's text, so screen readers announce it. Theme it with
|
|
241
|
+
`--aia-product-badge-bg`, `--aia-product-badge-color`,
|
|
242
|
+
`--aia-product-badge-font-size` and `--aia-product-badge-inset`, and the list
|
|
243
|
+
banner with `--aia-product-badge-list-bg`, `--aia-product-badge-list-color` and
|
|
244
|
+
`--aia-product-badge-list-font-size`.
|
|
245
|
+
|
|
232
246
|
Set the option at construction or change it through `update()`. Both
|
|
233
247
|
rendered tiers (`"full"` and `"dropdown"`) apply it to the visible cards:
|
|
234
248
|
|
|
@@ -340,7 +354,7 @@ new AIAutocomplete(container, {
|
|
|
340
354
|
});
|
|
341
355
|
```
|
|
342
356
|
|
|
343
|
-
`Product` is exactly
|
|
357
|
+
`Product` is exactly seven fields; only `id` and `title` are required:
|
|
344
358
|
|
|
345
359
|
```ts
|
|
346
360
|
type Product = {
|
|
@@ -350,6 +364,7 @@ type Product = {
|
|
|
350
364
|
imageUrl?: string | null; // null uses the configured productImageFallback
|
|
351
365
|
price?: string; // pre-formatted by you
|
|
352
366
|
vendor?: string;
|
|
367
|
+
available?: boolean; // false shows a "Sold out" badge
|
|
353
368
|
};
|
|
354
369
|
```
|
|
355
370
|
|
package/dist/index.d.mts
CHANGED
|
@@ -154,6 +154,18 @@ interface MatchedItem {
|
|
|
154
154
|
* item carries `handle` instead. When both are present the strip links here.
|
|
155
155
|
*/
|
|
156
156
|
item_url?: string;
|
|
157
|
+
/**
|
|
158
|
+
* The variant a filter in the query chose for this item ("blue", "size 10"),
|
|
159
|
+
* as the platform's numeric variant id. When set, `price` and `image_url`
|
|
160
|
+
* are that variant's, and the strip links to `/products/{handle}?variant=…`
|
|
161
|
+
* so the shopper lands on it.
|
|
162
|
+
*/
|
|
163
|
+
variant_id?: string;
|
|
164
|
+
/**
|
|
165
|
+
* Whether the item can be bought: `false` is sold out. Absent when the
|
|
166
|
+
* catalog doesn't say, which is not the same as sold out.
|
|
167
|
+
*/
|
|
168
|
+
available?: boolean;
|
|
157
169
|
}
|
|
158
170
|
/** The items the applied filters left standing. */
|
|
159
171
|
interface MatchedItems {
|
|
@@ -352,6 +364,12 @@ interface Product {
|
|
|
352
364
|
/** Pre-formatted by the integration, which is the side that knows the currency. */
|
|
353
365
|
price?: string;
|
|
354
366
|
vendor?: string;
|
|
367
|
+
/**
|
|
368
|
+
* `false` marks the card sold out: a "Sold out" badge over the image, and
|
|
369
|
+
* the image desaturated. The card stays selectable. Absent or `true` shows no
|
|
370
|
+
* badge — leave it out when availability is unknown.
|
|
371
|
+
*/
|
|
372
|
+
available?: boolean;
|
|
355
373
|
}
|
|
356
374
|
/**
|
|
357
375
|
* How the product strip lays its cards out. `"row"` is the horizontally
|
|
@@ -2181,9 +2199,10 @@ declare const PRODUCT_PATH_PREFIX = "/products/";
|
|
|
2181
2199
|
* `customFields` gets the same cards the built-in one draws.
|
|
2182
2200
|
*
|
|
2183
2201
|
* The link is the item's own `item_url` when the catalog named one, else the
|
|
2184
|
-
* `/products/{handle}` path a Shopify item implies
|
|
2185
|
-
* yields a card without a
|
|
2186
|
-
* `onProductSelect`, just nothing for
|
|
2202
|
+
* `/products/{handle}` path a Shopify item implies, opened on the chosen
|
|
2203
|
+
* variant when there is one. An item with neither yields a card without a
|
|
2204
|
+
* `url`: still activatable, still emitting `onProductSelect`, just nothing for
|
|
2205
|
+
* cmd-click to open.
|
|
2187
2206
|
*/
|
|
2188
2207
|
declare function productFromMatchedItem(item: MatchedItem): Product;
|
|
2189
2208
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -154,6 +154,18 @@ interface MatchedItem {
|
|
|
154
154
|
* item carries `handle` instead. When both are present the strip links here.
|
|
155
155
|
*/
|
|
156
156
|
item_url?: string;
|
|
157
|
+
/**
|
|
158
|
+
* The variant a filter in the query chose for this item ("blue", "size 10"),
|
|
159
|
+
* as the platform's numeric variant id. When set, `price` and `image_url`
|
|
160
|
+
* are that variant's, and the strip links to `/products/{handle}?variant=…`
|
|
161
|
+
* so the shopper lands on it.
|
|
162
|
+
*/
|
|
163
|
+
variant_id?: string;
|
|
164
|
+
/**
|
|
165
|
+
* Whether the item can be bought: `false` is sold out. Absent when the
|
|
166
|
+
* catalog doesn't say, which is not the same as sold out.
|
|
167
|
+
*/
|
|
168
|
+
available?: boolean;
|
|
157
169
|
}
|
|
158
170
|
/** The items the applied filters left standing. */
|
|
159
171
|
interface MatchedItems {
|
|
@@ -352,6 +364,12 @@ interface Product {
|
|
|
352
364
|
/** Pre-formatted by the integration, which is the side that knows the currency. */
|
|
353
365
|
price?: string;
|
|
354
366
|
vendor?: string;
|
|
367
|
+
/**
|
|
368
|
+
* `false` marks the card sold out: a "Sold out" badge over the image, and
|
|
369
|
+
* the image desaturated. The card stays selectable. Absent or `true` shows no
|
|
370
|
+
* badge — leave it out when availability is unknown.
|
|
371
|
+
*/
|
|
372
|
+
available?: boolean;
|
|
355
373
|
}
|
|
356
374
|
/**
|
|
357
375
|
* How the product strip lays its cards out. `"row"` is the horizontally
|
|
@@ -2181,9 +2199,10 @@ declare const PRODUCT_PATH_PREFIX = "/products/";
|
|
|
2181
2199
|
* `customFields` gets the same cards the built-in one draws.
|
|
2182
2200
|
*
|
|
2183
2201
|
* The link is the item's own `item_url` when the catalog named one, else the
|
|
2184
|
-
* `/products/{handle}` path a Shopify item implies
|
|
2185
|
-
* yields a card without a
|
|
2186
|
-
* `onProductSelect`, just nothing for
|
|
2202
|
+
* `/products/{handle}` path a Shopify item implies, opened on the chosen
|
|
2203
|
+
* variant when there is one. An item with neither yields a card without a
|
|
2204
|
+
* `url`: still activatable, still emitting `onProductSelect`, just nothing for
|
|
2205
|
+
* cmd-click to open.
|
|
2187
2206
|
*/
|
|
2188
2207
|
declare function productFromMatchedItem(item: MatchedItem): Product;
|
|
2189
2208
|
/**
|