@magicx-eng/ai-autocomplete-angular 0.31.4 → 0.31.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/esm2020/lib/internal/product-strip/product-strip.component.mjs +15 -9
- package/esm2020/lib/internal/suggestion-item/suggestion-item.component.mjs +19 -8
- package/esm2020/public-api.mjs +4 -2
- package/fesm2015/magicx-eng-ai-autocomplete-angular.mjs +37 -16
- package/fesm2015/magicx-eng-ai-autocomplete-angular.mjs.map +1 -1
- package/fesm2020/magicx-eng-ai-autocomplete-angular.mjs +34 -15
- package/fesm2020/magicx-eng-ai-autocomplete-angular.mjs.map +1 -1
- package/lib/internal/product-strip/product-strip.component.d.ts +5 -0
- package/lib/internal/product-strip/product-strip.component.d.ts.map +1 -1
- package/lib/internal/suggestion-item/suggestion-item.component.d.ts +8 -3
- package/lib/internal/suggestion-item/suggestion-item.component.d.ts.map +1 -1
- package/package.json +2 -2
- package/public-api.d.ts +3 -1
- package/public-api.d.ts.map +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WEEKDAY_LABELS as WEEKDAY_LABELS$1, cellIso as cellIso$1, monthLabel as monthLabel$1, cellDay as cellDay$1, isoDate as isoDate$1, dateCellMarks as dateCellMarks$1, visibleDateRange as visibleDateRange$1, productInitial, attachProductRowWheel, optionsGridTemplateColumns, optionLabel as optionLabel$1,
|
|
1
|
+
import { WEEKDAY_LABELS as WEEKDAY_LABELS$1, cellIso as cellIso$1, monthLabel as monthLabel$1, cellDay as cellDay$1, isoDate as isoDate$1, dateCellMarks as dateCellMarks$1, visibleDateRange as visibleDateRange$1, productInitial, productImageSources as productImageSources$1, attachProductRowWheel, optionsGridTemplateColumns, optionLabel as optionLabel$1, optionImageSources as optionImageSources$1, formatOptionCount as formatOptionCount$1, sanitizeOptionIconSvg as sanitizeOptionIconSvg$1, planOptionsGrid, sameOptionRows, isOptionsGridMobileViewport, needsOptionsGridMeasurement, measureOptionsGrid, optionEnterDelayMs, SCROLL_ARROW_LABEL, buildAttributionUrl, containScroll, attachScrollArrow, isCalendarFormat, getFooterHint, AIAutocomplete, dateSelectionFor, identifiedParamLabel, renderEditableContent, chipIdFromTap, keepCaretOnChip, getCursorOffset, extractPlainText, plainTextLength, setCursorOffset, ModeController, buildSubmitResult as buildSubmitResult$1, withSkippedParams as withSkippedParams$1, formatDate as formatDate$1, parseDate as parseDate$1, parseLooseDate as parseLooseDate$1, DATE_RANGE_META_END as DATE_RANGE_META_END$1, DATE_RANGE_META_START as DATE_RANGE_META_START$1, formatDateRange as formatDateRange$1, parseLooseDateRange as parseLooseDateRange$1, selectedRangeFor as selectedRangeFor$1, DEFAULT_OPTION_COUNT_UNIT as DEFAULT_OPTION_COUNT_UNIT$1, optionCountLabel as optionCountLabel$1, optionHasImage as optionHasImage$1, optionImageSrc as optionImageSrc$1, PRODUCT_PATH_PREFIX as PRODUCT_PATH_PREFIX$1, productFromMatchedItem as productFromMatchedItem$1, productsFromCustomFields as productsFromCustomFields$1 } from '@magicx-eng/ai-autocomplete-vanilla';
|
|
2
2
|
import * as i1 from '@angular/common';
|
|
3
3
|
import { CommonModule, isPlatformBrowser } from '@angular/common';
|
|
4
4
|
import * as i0 from '@angular/core';
|
|
@@ -317,6 +317,11 @@ class ProductStripComponent {
|
|
|
317
317
|
this.layout = "row";
|
|
318
318
|
this.imageFallback = "image";
|
|
319
319
|
this.initial = productInitial;
|
|
320
|
+
/**
|
|
321
|
+
* Per product id, the `src`s that failed to load: a card moves on to the
|
|
322
|
+
* next source (a Shopify thumbnail falls back to the original) and shows its
|
|
323
|
+
* placeholder once none is left.
|
|
324
|
+
*/
|
|
320
325
|
this.failedImages = new Map();
|
|
321
326
|
this.select = new EventEmitter();
|
|
322
327
|
/**
|
|
@@ -342,20 +347,21 @@ class ProductStripComponent {
|
|
|
342
347
|
].join("\0");
|
|
343
348
|
}
|
|
344
349
|
ngOnChanges() {
|
|
345
|
-
const sources = new Map(this.products.map((product) => [product.id, product.imageUrl
|
|
346
|
-
for (const [id,
|
|
347
|
-
|
|
350
|
+
const sources = new Map(this.products.map((product) => [product.id, productImageSources$1(product.imageUrl)]));
|
|
351
|
+
for (const [id, failed] of this.failedImages) {
|
|
352
|
+
const current = sources.get(id) ?? [];
|
|
353
|
+
if (!failed.every((src) => current.includes(src)))
|
|
348
354
|
this.failedImages.delete(id);
|
|
349
355
|
}
|
|
350
356
|
}
|
|
351
357
|
imageSource(product) {
|
|
352
|
-
const
|
|
353
|
-
return
|
|
358
|
+
const failed = this.failedImages.get(product.id) ?? [];
|
|
359
|
+
return productImageSources$1(product.imageUrl).find((src) => !failed.includes(src)) ?? null;
|
|
354
360
|
}
|
|
355
361
|
onImageError(product) {
|
|
356
|
-
const src =
|
|
362
|
+
const src = this.imageSource(product);
|
|
357
363
|
if (src)
|
|
358
|
-
this.failedImages.set(product.id, src);
|
|
364
|
+
this.failedImages.set(product.id, [...(this.failedImages.get(product.id) ?? []), src]);
|
|
359
365
|
}
|
|
360
366
|
/**
|
|
361
367
|
* A mouse wheel over the row scrolls it sideways. The row sits inside the
|
|
@@ -541,8 +547,12 @@ class SuggestionItemComponent {
|
|
|
541
547
|
this.cdr = inject(ChangeDetectorRef);
|
|
542
548
|
this.sanitizer = inject(DomSanitizer);
|
|
543
549
|
this.iconSafe = null;
|
|
544
|
-
/**
|
|
545
|
-
|
|
550
|
+
/**
|
|
551
|
+
* The `src`s that failed to load: the row moves on to the next source (a
|
|
552
|
+
* Shopify thumbnail falls back to the original), and the tile keeps its
|
|
553
|
+
* placeholder fill once none is left.
|
|
554
|
+
*/
|
|
555
|
+
this.failedSrcs = [];
|
|
546
556
|
}
|
|
547
557
|
/**
|
|
548
558
|
* Start delay of this row's entrance animation (ms) — each row rises in a
|
|
@@ -563,16 +573,23 @@ class SuggestionItemComponent {
|
|
|
563
573
|
* the icon — a row never leads with two visuals.
|
|
564
574
|
*/
|
|
565
575
|
get imageSrc() {
|
|
566
|
-
|
|
576
|
+
const sources = this.imageSources;
|
|
577
|
+
return (sources.find((src) => !this.failedSrcs.includes(src)) ?? sources[sources.length - 1] ?? null);
|
|
567
578
|
}
|
|
568
|
-
/** Whether the
|
|
579
|
+
/** Whether every source of the picture failed to load (the tile's fill stays). */
|
|
569
580
|
get imageFailed() {
|
|
570
|
-
|
|
581
|
+
const sources = this.imageSources;
|
|
582
|
+
return sources.length > 0 && sources.every((src) => this.failedSrcs.includes(src));
|
|
571
583
|
}
|
|
572
584
|
onImageError() {
|
|
573
|
-
|
|
585
|
+
const src = this.imageSrc;
|
|
586
|
+
if (src !== null && !this.failedSrcs.includes(src))
|
|
587
|
+
this.failedSrcs = [...this.failedSrcs, src];
|
|
574
588
|
this.cdr.markForCheck();
|
|
575
589
|
}
|
|
590
|
+
get imageSources() {
|
|
591
|
+
return this.showImage ? optionImageSources$1(this.option.image_url) : [];
|
|
592
|
+
}
|
|
576
593
|
/**
|
|
577
594
|
* The count as printed ("1,284"), or `null` when the row shows none. The
|
|
578
595
|
* unit word after it is the stylesheet's (`--aia-option-count-unit`).
|
|
@@ -2813,14 +2830,16 @@ const formatOptionCount = formatOptionCount$1;
|
|
|
2813
2830
|
const optionCountLabel = optionCountLabel$1;
|
|
2814
2831
|
const optionHasImage = optionHasImage$1;
|
|
2815
2832
|
const optionImageSrc = optionImageSrc$1;
|
|
2833
|
+
const optionImageSources = optionImageSources$1;
|
|
2816
2834
|
// Product strip helpers, for a custom strip fed from `customFields$`.
|
|
2817
2835
|
const PRODUCT_PATH_PREFIX = PRODUCT_PATH_PREFIX$1;
|
|
2818
2836
|
const productFromMatchedItem = productFromMatchedItem$1;
|
|
2837
|
+
const productImageSources = productImageSources$1;
|
|
2819
2838
|
const productsFromCustomFields = productsFromCustomFields$1;
|
|
2820
2839
|
|
|
2821
2840
|
/**
|
|
2822
2841
|
* Generated bundle index. Do not edit.
|
|
2823
2842
|
*/
|
|
2824
2843
|
|
|
2825
|
-
export { AIAutocompleteComponent, AIAutocompleteController, AIAutocompleteDropdownComponent, AIAutocompleteInputDirective, AIAutocompleteModule, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, PRODUCT_PATH_PREFIX, WEEKDAY_LABELS, buildSubmitResult, cellDay, cellIso, dateCellMarks, formatDate, formatDateRange, formatOptionCount, isoDate, monthLabel, optionCountLabel, optionHasImage, optionImageSrc, optionLabel, parseDate, parseLooseDate, parseLooseDateRange, productFromMatchedItem, productsFromCustomFields, sanitizeOptionIconSvg, selectedRangeFor, visibleDateRange, withSkippedParams };
|
|
2844
|
+
export { AIAutocompleteComponent, AIAutocompleteController, AIAutocompleteDropdownComponent, AIAutocompleteInputDirective, AIAutocompleteModule, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, PRODUCT_PATH_PREFIX, WEEKDAY_LABELS, buildSubmitResult, cellDay, cellIso, dateCellMarks, formatDate, formatDateRange, formatOptionCount, isoDate, monthLabel, optionCountLabel, optionHasImage, optionImageSources, optionImageSrc, optionLabel, parseDate, parseLooseDate, parseLooseDateRange, productFromMatchedItem, productImageSources, productsFromCustomFields, sanitizeOptionIconSvg, selectedRangeFor, visibleDateRange, withSkippedParams };
|
|
2826
2845
|
//# sourceMappingURL=magicx-eng-ai-autocomplete-angular.mjs.map
|