@eldrajs/theme-cli 0.2.1 → 0.2.3
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/package.json +3 -3
- package/template/.eldra/previews.json +35 -35
- package/template/.github/workflows/eldra-deploy.yml +29 -2
- package/template/.gitlab-ci.yml +37 -10
- package/template/README.md +4 -4
- package/template/app/composables/useFormSpam.ts +1 -0
- package/template/app/plugins/chunk-reload.client.ts +29 -0
- package/template/app/plugins/eldra-storefront.ts +8 -0
- package/template/app/storefront/gateway.ts +34 -11
- package/template/app/storefront/sharedRead.ts +34 -0
- package/template/app/storefront/structuredData.ts +17 -0
- package/template/app/utils/chunkReload.ts +11 -0
- package/template/bitbucket-pipelines.yml +26 -6
- package/template/blocks/announcement-bar/preview.png +0 -0
- package/template/blocks/article/preview.png +0 -0
- package/template/blocks/article-list/preview.png +0 -0
- package/template/blocks/breadcrumbs/preview.png +0 -0
- package/template/blocks/cart/preview.png +0 -0
- package/template/blocks/collection-grid/Block.vue +146 -94
- package/template/blocks/collection-grid/__tests__/Block.spec.ts +116 -2
- package/template/blocks/collection-grid/preview.png +0 -0
- package/template/blocks/collection-header/preview.png +0 -0
- package/template/blocks/contact/preview.png +0 -0
- package/template/blocks/cta/preview.png +0 -0
- package/template/blocks/faq/preview.png +0 -0
- package/template/blocks/feature-grid/preview.png +0 -0
- package/template/blocks/footer/Block.vue +11 -4
- package/template/blocks/footer/__tests__/Block.spec.ts +68 -3
- package/template/blocks/footer/preview.png +0 -0
- package/template/blocks/form/preview.png +0 -0
- package/template/blocks/gallery/preview.png +0 -0
- package/template/blocks/hero/preview.png +0 -0
- package/template/blocks/image/preview.png +0 -0
- package/template/blocks/logo-cloud/preview.png +0 -0
- package/template/blocks/navigation/Block.vue +125 -541
- package/template/blocks/navigation/__tests__/Block.spec.ts +172 -73
- package/template/blocks/navigation/parts/MenuLink.vue +15 -0
- package/template/blocks/navigation/preview.png +0 -0
- package/template/blocks/newsletter/preview.png +0 -0
- package/template/blocks/order-status/preview.png +0 -0
- package/template/blocks/pricing-table/preview.png +0 -0
- package/template/blocks/product-carousel/preview.png +0 -0
- package/template/blocks/product-detail/preview.png +0 -0
- package/template/blocks/quote/preview.png +0 -0
- package/template/blocks/rich-text/preview.png +0 -0
- package/template/blocks/search/preview.png +0 -0
- package/template/blocks/split-content/preview.png +0 -0
- package/template/blocks/stats/preview.png +0 -0
- package/template/blocks/tabs/preview.png +0 -0
- package/template/blocks/team/preview.png +0 -0
- package/template/blocks/testimonials/preview.png +0 -0
- package/template/blocks/timeline/preview.png +0 -0
- package/template/blocks/trust-strip/preview.png +0 -0
- package/template/blocks/video-embed/preview.png +0 -0
- package/template/blocks/wishlist/preview.png +0 -0
- package/template/test/chunkReload.spec.ts +20 -0
- package/template/test/imageFraming.browser.spec.ts +125 -0
- package/template/test/pages/article.spec.ts +1 -1
- package/template/test/pages/collection.spec.ts +1 -1
- package/template/test/pages/home.spec.ts +1 -1
- package/template/test/pages/product.spec.ts +1 -1
- package/template/test/prerenderRefresh.browser.spec.ts +8 -13
- package/template/test/storefront/gateway.spec.ts +6 -0
- package/template/test/storefront/gatewayPrerender.spec.ts +26 -1
- package/template/test/storefront/sharedRead.spec.ts +43 -0
- package/template/test/storefront/structuredData.spec.ts +31 -0
- package/template/blocks/navigation/useMegaMenuKeys.ts +0 -276
|
@@ -89,7 +89,7 @@ import {
|
|
|
89
89
|
selectorNeedsPublish,
|
|
90
90
|
selectorSlug,
|
|
91
91
|
} from '../../app/storefront/collectionSelector';
|
|
92
|
-
import type { StorefrontCollectionSelector } from '../../app/storefront/types';
|
|
92
|
+
import type { CatalogFacets, StorefrontCollectionSelector } from '../../app/storefront/types';
|
|
93
93
|
import { canonicalAvailabilityValues } from '../../app/storefront/facets';
|
|
94
94
|
import { CATALOGUE_PATH } from '../../app/storefront/categories';
|
|
95
95
|
import { categoryHref, safeHref } from '../../app/utils/links';
|
|
@@ -832,7 +832,7 @@ const skeletonCount = computed(() =>
|
|
|
832
832
|
* is at least the merchant's own word. A toggle source never reaches here — it is folded into the
|
|
833
833
|
* `availability` facet, which keeps its own label.
|
|
834
834
|
*/
|
|
835
|
-
function defaultFacetLabel(source: FilterSource): string {
|
|
835
|
+
function defaultFacetLabel(source: FilterSource, names: ReadonlyMap<string, string>): string {
|
|
836
836
|
if (source === 'price') return t('grid.price');
|
|
837
837
|
if (source === 'category') return t('grid.legendCategory');
|
|
838
838
|
if (source === 'collection') return t('grid.legendCollection');
|
|
@@ -840,14 +840,9 @@ function defaultFacetLabel(source: FilterSource): string {
|
|
|
840
840
|
const key = optionKeyOf(source);
|
|
841
841
|
if (key === 'size') return t('grid.legendSize');
|
|
842
842
|
if (key === 'colour') return t('grid.legendColour');
|
|
843
|
-
return
|
|
843
|
+
return names.get(key ?? '') ?? key ?? source;
|
|
844
844
|
}
|
|
845
845
|
|
|
846
|
-
/** Each option key's own display name, as the storefront's facets report it. */
|
|
847
|
-
const optionNames = computed(
|
|
848
|
-
() => new Map((facets.value?.options ?? []).map((option) => [option.key, option.name] as const))
|
|
849
|
-
);
|
|
850
|
-
|
|
851
846
|
/** The combined `availability` facet's own values' names: the facets carry counts, never labels —
|
|
852
847
|
* "In stock only" is the one switch row the theme names itself (spec → Variants, `toggle` facet). */
|
|
853
848
|
const availabilityLabels = computed(() => ({
|
|
@@ -899,13 +894,6 @@ watch(selected, () => {
|
|
|
899
894
|
loadedPriceSpan.value = null;
|
|
900
895
|
});
|
|
901
896
|
const EMPTY_SPAN: PriceSpan = { min: 0, max: 0 };
|
|
902
|
-
const priceSpan = computed<PriceSpan>(() =>
|
|
903
|
-
spanWithRange(facetPriceSpan.value ?? loadedPriceSpan.value ?? EMPTY_SPAN, {
|
|
904
|
-
min: priceMin.value,
|
|
905
|
-
max: priceMax.value,
|
|
906
|
-
})
|
|
907
|
-
);
|
|
908
|
-
|
|
909
897
|
/**
|
|
910
898
|
* The price slider's step: the author's `priceStep`, else one unit of the store currency (ISK 100,
|
|
911
899
|
* USD 1 — `defaultPriceStep`), narrowed to a step this catalogue's own span can actually hold
|
|
@@ -925,88 +913,129 @@ const priceSpan = computed<PriceSpan>(() =>
|
|
|
925
913
|
*/
|
|
926
914
|
const priceSlider = computed(() => data.value.priceSlider !== false);
|
|
927
915
|
|
|
928
|
-
const priceStep = computed(() => {
|
|
929
|
-
const own = data.value.priceStep;
|
|
930
|
-
if (typeof own === 'number' && Number.isFinite(own) && own > 0) return own;
|
|
931
|
-
return fitPriceStep(defaultPriceStep(money.currency.value), priceSpan.value);
|
|
932
|
-
});
|
|
933
|
-
|
|
934
916
|
/**
|
|
935
|
-
* **
|
|
936
|
-
*
|
|
937
|
-
*
|
|
917
|
+
* **Everything the filter panel derives from one facets answer**, as a function of three inputs: the
|
|
918
|
+
* facets, the selection they are shown under, and the price range held beside it. Called twice — the
|
|
919
|
+
* applied view (`filterFacets`, the sidebar and the chips) and the drawer's own view over the
|
|
920
|
+
* pending read's facets and the pending selection (`drawerView`) — because the drawer's panel has to
|
|
921
|
+
* describe *its* selection, not the page's: unticking the one filter that narrowed the page to
|
|
922
|
+
* nothing else must bring the groups that filter had hidden back while the drawer is still open.
|
|
923
|
+
*
|
|
924
|
+
* `expandedFilterRows` is the author's rows expanded into rendered sources, which is the whole of
|
|
925
|
+
* what `options` means: in its place, one `option:<key>` row per option key the facets answer, in
|
|
926
|
+
* the facets' order, carrying no label of its own (the group then takes the store's own name for
|
|
927
|
+
* that key). A key an explicit `option:<key>` row already names is **not** expanded again: that row
|
|
928
|
+
* wins, wherever the author put it. So "Size first, then whatever else this store sells by" is two
|
|
929
|
+
* rows, and the common case — "every option, in the store's order" — is one.
|
|
938
930
|
*
|
|
939
|
-
*
|
|
940
|
-
*
|
|
941
|
-
* by
|
|
931
|
+
* `filterFacets` is **the one call into the adapter**: `buildFilterFacets` (`parts/groups.ts`) turns
|
|
932
|
+
* those rows and the facets into the `FilterFacet[]` `FilterPanel` draws — a source this scope cannot
|
|
933
|
+
* narrow by, or one with nothing to offer, is dropped there. A range with fewer than two distinct
|
|
934
|
+
* values is still included: the package's own `renderableFacets` drops it.
|
|
942
935
|
*/
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
936
|
+
function facetViewFor(
|
|
937
|
+
facetsOf: () => CatalogFacets | undefined,
|
|
938
|
+
selectionOf: () => FilterSelection,
|
|
939
|
+
rangeOf: () => PriceRange
|
|
940
|
+
) {
|
|
941
|
+
/** Each option key's own display name, as the storefront's facets report it. */
|
|
942
|
+
const optionNames = computed(
|
|
943
|
+
() => new Map((facetsOf()?.options ?? []).map((option) => [option.key, option.name] as const))
|
|
946
944
|
);
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
945
|
+
|
|
946
|
+
const priceSpan = computed<PriceSpan>(() =>
|
|
947
|
+
spanWithRange(facetsOf()?.price ?? loadedPriceSpan.value ?? EMPTY_SPAN, rangeOf())
|
|
948
|
+
);
|
|
949
|
+
|
|
950
|
+
/**
|
|
951
|
+
* The price slider's step: the author's `priceStep`, else one unit of the store currency (ISK 100,
|
|
952
|
+
* USD 1 — `defaultPriceStep`), narrowed to a step this catalogue's own span can actually hold
|
|
953
|
+
* (`fitPriceStep`). A non-positive or non-integer field value is no step at all, so it falls back
|
|
954
|
+
* rather than handing the slider a grid it cannot land on.
|
|
955
|
+
*/
|
|
956
|
+
const priceStep = computed(() => {
|
|
957
|
+
const own = data.value.priceStep;
|
|
958
|
+
if (typeof own === 'number' && Number.isFinite(own) && own > 0) return own;
|
|
959
|
+
return fitPriceStep(defaultPriceStep(money.currency.value), priceSpan.value);
|
|
960
|
+
});
|
|
961
|
+
|
|
962
|
+
const expandedFilterRows = computed<Array<FilterField & { source: FilterSource }>>(() => {
|
|
963
|
+
const explicitKeys = new Set(
|
|
964
|
+
filterFields.value.map((row) => optionKeyOf(row.source)).filter((key) => key !== null)
|
|
965
|
+
);
|
|
966
|
+
const out: Array<FilterField & { source: FilterSource }> = [];
|
|
967
|
+
for (const row of filterFields.value) {
|
|
968
|
+
if (row.source !== 'options') {
|
|
969
|
+
out.push({ ...row, source: row.source });
|
|
965
970
|
continue;
|
|
966
971
|
}
|
|
967
|
-
|
|
972
|
+
// The facets' own keys, in the facets' order — plus any key the shopper already has a filter on
|
|
973
|
+
// that the facets have stopped naming. That second half is the standing rule that a group
|
|
974
|
+
// carrying a selection is never dropped out from under an applied filter: facets are computed
|
|
975
|
+
// over the current result set on most backends, so a narrowing filter can remove the very family
|
|
976
|
+
// it was set in, and a group that vanished would leave the shopper no control to undo it.
|
|
977
|
+
for (const key of [
|
|
978
|
+
...(facetsOf()?.options ?? []).map((option) => option.key),
|
|
979
|
+
...Object.keys(selectionOf()).map(optionKeyOf),
|
|
980
|
+
]
|
|
981
|
+
.map(usableOptionKey)
|
|
982
|
+
.filter((key): key is string => key !== null)) {
|
|
983
|
+
if (explicitKeys.has(key) || out.some((done) => done.source === optionSourceFor(key))) {
|
|
984
|
+
continue;
|
|
985
|
+
}
|
|
986
|
+
out.push({ ...row, label: undefined, source: optionSourceFor(key) });
|
|
987
|
+
}
|
|
968
988
|
}
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
});
|
|
989
|
+
return out;
|
|
990
|
+
});
|
|
972
991
|
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
})
|
|
999
|
-
);
|
|
992
|
+
const filterFacets = computed<FilterFacet[]>(() =>
|
|
993
|
+
buildFilterFacets(expandedFilterRows.value, {
|
|
994
|
+
facets: facetsOf(),
|
|
995
|
+
selection: selectionOf(),
|
|
996
|
+
availability: availabilityLabels.value,
|
|
997
|
+
categoryScopeSlug: categoryScopeSlug.value,
|
|
998
|
+
unfilterable: unfilterableSources.value,
|
|
999
|
+
labelFor: (source) => defaultFacetLabel(source, optionNames.value),
|
|
1000
|
+
colourLayout: colourLayout.value,
|
|
1001
|
+
sizeGuideHref: sizeGuideHref.value,
|
|
1002
|
+
price: {
|
|
1003
|
+
min: priceSpan.value.min,
|
|
1004
|
+
max: priceSpan.value.max,
|
|
1005
|
+
step: priceStep.value,
|
|
1006
|
+
slider: priceSlider.value,
|
|
1007
|
+
currency: money.currency.value !== undefined,
|
|
1008
|
+
...(facetsOf()?.price?.histogram ? { histogram: facetsOf()!.price!.histogram } : {}),
|
|
1009
|
+
},
|
|
1010
|
+
})
|
|
1011
|
+
);
|
|
1012
|
+
|
|
1013
|
+
/** Every rendered source's own `FilterSource`, by the `FilterFacet.id` the panel uses — the reverse
|
|
1014
|
+
* of `queryKeyFor`, for translating the panel's own selection back into the block's internal one
|
|
1015
|
+
* (`applyPanelSelection`, called from `onPanelChange`/`onPendingPanelChange`). */
|
|
1016
|
+
const sourceMap = computed(() => facetSourceMap(expandedFilterRows.value));
|
|
1000
1017
|
|
|
1001
|
-
/**
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1018
|
+
/** This view's toggle keys (`facets.toggles[]`), so `applyPanelSelection` can tell a known
|
|
1019
|
+
* toggle apart from an unknown `availability` array member (a stale value nothing lists any more). */
|
|
1020
|
+
const toggleKeySet = computed(
|
|
1021
|
+
() => new Set((facetsOf()?.toggles ?? []).map((toggle) => toggle.key))
|
|
1022
|
+
);
|
|
1005
1023
|
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1024
|
+
return {
|
|
1025
|
+
optionNames,
|
|
1026
|
+
priceSpan,
|
|
1027
|
+
priceStep,
|
|
1028
|
+
expandedFilterRows,
|
|
1029
|
+
filterFacets,
|
|
1030
|
+
sourceMap,
|
|
1031
|
+
toggleKeySet,
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
const { priceSpan, filterFacets, sourceMap, toggleKeySet } = facetViewFor(
|
|
1036
|
+
() => facets.value,
|
|
1037
|
+
() => selection.value,
|
|
1038
|
+
() => ({ min: priceMin.value, max: priceMax.value })
|
|
1010
1039
|
);
|
|
1011
1040
|
|
|
1012
1041
|
/** The sidebar panel's own live (applied) selection, keyed by facet id. One-way: the panel is
|
|
@@ -1020,7 +1049,7 @@ const pendingPanelSelection = computed<UiFilterSelection>(() =>
|
|
|
1020
1049
|
panelSelectionFor(
|
|
1021
1050
|
pendingSelection.value,
|
|
1022
1051
|
{ min: pendingMin.value, max: pendingMax.value },
|
|
1023
|
-
priceSpan.value
|
|
1052
|
+
drawerView.priceSpan.value
|
|
1024
1053
|
)
|
|
1025
1054
|
);
|
|
1026
1055
|
|
|
@@ -1406,22 +1435,45 @@ const pendingProducts = storeWideScope.value
|
|
|
1406
1435
|
: storefront.catalog.collectionProducts(pendingSelected, pendingOptions);
|
|
1407
1436
|
const pendingTotal = computed(() => pendingProducts.data.value?.total ?? total.value);
|
|
1408
1437
|
|
|
1438
|
+
/**
|
|
1439
|
+
* The facets the drawer panel draws from: the pending read's, so the groups follow the *pending*
|
|
1440
|
+
* selection (untick the filter that narrowed the page and the groups it hid come back before
|
|
1441
|
+
* "Show N products" is pressed). Only an answered, settled read counts — a read in flight keeps the
|
|
1442
|
+
* last answer rather than flashing back to the applied facets between two ticks — and until the
|
|
1443
|
+
* first one lands, or after a reopen that changes the filters, the applied facets stand in so the
|
|
1444
|
+
* panel is never empty.
|
|
1445
|
+
*/
|
|
1446
|
+
const settledPendingFacets = ref<CatalogFacets | undefined>();
|
|
1447
|
+
watch([pendingProducts.data, pendingProducts.loading], ([answer, loading]) => {
|
|
1448
|
+
if (drawerUsed.value && !loading && answer) settledPendingFacets.value = answer.facets;
|
|
1449
|
+
});
|
|
1450
|
+
const drawerFacets = computed(() => settledPendingFacets.value ?? facets.value);
|
|
1451
|
+
const drawerView = facetViewFor(
|
|
1452
|
+
() => drawerFacets.value,
|
|
1453
|
+
() => pendingSelection.value,
|
|
1454
|
+
() => ({ min: pendingMin.value, max: pendingMax.value })
|
|
1455
|
+
);
|
|
1456
|
+
|
|
1409
1457
|
function openDrawer(): void {
|
|
1458
|
+
const before = JSON.stringify(debouncedPendingFilters.value);
|
|
1410
1459
|
pendingSelection.value = { ...selection.value };
|
|
1411
1460
|
pendingMin.value = priceMin.value;
|
|
1412
1461
|
pendingMax.value = priceMax.value;
|
|
1413
1462
|
drawerUsed.value = true;
|
|
1414
1463
|
drawerOpen.value = true;
|
|
1415
1464
|
flushPendingDebounce();
|
|
1465
|
+
// Reopened over different filters than the last answer was for: it describes another selection.
|
|
1466
|
+
if (JSON.stringify(debouncedPendingFilters.value) !== before)
|
|
1467
|
+
settledPendingFacets.value = undefined;
|
|
1416
1468
|
}
|
|
1417
1469
|
/** The drawer's own path: every kind of change the panel reports, applied to the *pending* copy —
|
|
1418
1470
|
* nothing here reaches the page until `applyPending()`. */
|
|
1419
1471
|
function onPendingPanelChange(next: UiFilterSelection): void {
|
|
1420
|
-
lastPendingChips = appliedFilters(filterFacets.value, pendingPanelSelection.value);
|
|
1472
|
+
lastPendingChips = appliedFilters(drawerView.filterFacets.value, pendingPanelSelection.value);
|
|
1421
1473
|
const applied = applyPanelSelection(next, {
|
|
1422
|
-
sources: sourceMap.value,
|
|
1423
|
-
toggleKeys: toggleKeySet.value,
|
|
1424
|
-
priceSpan: priceSpan.value,
|
|
1474
|
+
sources: drawerView.sourceMap.value,
|
|
1475
|
+
toggleKeys: drawerView.toggleKeySet.value,
|
|
1476
|
+
priceSpan: drawerView.priceSpan.value,
|
|
1425
1477
|
appliedPrice: { min: pendingMin.value, max: pendingMax.value },
|
|
1426
1478
|
});
|
|
1427
1479
|
pendingSelection.value = applied.selection;
|
|
@@ -1441,7 +1493,7 @@ async function onPendingPanelRemove(removal: { facetId: string; value: string })
|
|
|
1441
1493
|
);
|
|
1442
1494
|
flushPendingDebounce();
|
|
1443
1495
|
await nextTick();
|
|
1444
|
-
const remaining = appliedFilters(filterFacets.value, pendingPanelSelection.value);
|
|
1496
|
+
const remaining = appliedFilters(drawerView.filterFacets.value, pendingPanelSelection.value);
|
|
1445
1497
|
if (remaining.length === 0 || index < 0) return;
|
|
1446
1498
|
focusNthRemoveButton(drawerPanelEl.value, Math.min(index, remaining.length - 1));
|
|
1447
1499
|
}
|
|
@@ -1801,7 +1853,7 @@ function hrefForPage(page: number): string {
|
|
|
1801
1853
|
mode="drawer"
|
|
1802
1854
|
:show-head="false"
|
|
1803
1855
|
show-applied
|
|
1804
|
-
:facets="filterFacets"
|
|
1856
|
+
:facets="drawerView.filterFacets.value"
|
|
1805
1857
|
:model-value="pendingPanelSelection"
|
|
1806
1858
|
:currency="money.currency.value"
|
|
1807
1859
|
:result-count="pendingTotal"
|
|
@@ -96,6 +96,8 @@ interface Stub {
|
|
|
96
96
|
revalidating: Ref<ReadonlySet<VolatileKey>>;
|
|
97
97
|
/** Set by a test to fail the read *after* it has already answered once. */
|
|
98
98
|
error: Ref<string | null>;
|
|
99
|
+
/** Flipped by a test to hold the drawer's count read (`pageSize: 1`) unanswered: `data` is null. */
|
|
100
|
+
holdCountReads: Ref<boolean>;
|
|
99
101
|
/** Every `collectionProducts` request, newest last — the grid's and the drawer's pending count. */
|
|
100
102
|
requests: Array<{ pageSize: number; sort?: string; filters?: Record<string, string[]> }>;
|
|
101
103
|
}
|
|
@@ -128,6 +130,7 @@ function createStub(
|
|
|
128
130
|
const loading = ref(false);
|
|
129
131
|
const revalidating = ref<ReadonlySet<VolatileKey>>(new Set());
|
|
130
132
|
const error = ref<string | null>(null);
|
|
133
|
+
const holdCountReads = ref(false);
|
|
131
134
|
const requests: Stub['requests'] = [];
|
|
132
135
|
const filteredCount = options.filteredCount ?? 0;
|
|
133
136
|
const catalog: StorefrontCatalog = {
|
|
@@ -136,6 +139,7 @@ function createStub(
|
|
|
136
139
|
watch(opts, (value) => requests.push({ ...value }), { deep: true });
|
|
137
140
|
const data = computed(() => {
|
|
138
141
|
if (collection.value === null) return null;
|
|
142
|
+
if (opts.value.pageSize === 1 && holdCountReads.value) return null;
|
|
139
143
|
const filtered = opts.value.filters !== undefined;
|
|
140
144
|
return {
|
|
141
145
|
items: filtered ? items.slice(0, filteredCount) : items.slice(0, opts.value.pageSize),
|
|
@@ -157,7 +161,15 @@ function createStub(
|
|
|
157
161
|
} as unknown as StorefrontResult<StorefrontCollectionProducts>;
|
|
158
162
|
},
|
|
159
163
|
};
|
|
160
|
-
return {
|
|
164
|
+
return {
|
|
165
|
+
source: { ...base, catalog },
|
|
166
|
+
pending,
|
|
167
|
+
loading,
|
|
168
|
+
revalidating,
|
|
169
|
+
error,
|
|
170
|
+
holdCountReads,
|
|
171
|
+
requests,
|
|
172
|
+
};
|
|
161
173
|
}
|
|
162
174
|
|
|
163
175
|
/** A storefront whose collection read is still on its very first load: `pending`, and no data at
|
|
@@ -940,6 +952,108 @@ describe('collection-grid block', () => {
|
|
|
940
952
|
});
|
|
941
953
|
});
|
|
942
954
|
|
|
955
|
+
describe('the drawer’s facets follow the pending selection', () => {
|
|
956
|
+
/** The page narrowed by Size M answers facets with no Colour group; the unfiltered answer (what
|
|
957
|
+
* the drawer's own count read gets once Size is unticked inside it) lists Colour, counted 77. */
|
|
958
|
+
const withoutColour: CatalogFacets = {
|
|
959
|
+
...FACETS,
|
|
960
|
+
options: FACETS.options.filter((option) => option.key !== 'colour'),
|
|
961
|
+
};
|
|
962
|
+
const withColour: CatalogFacets = {
|
|
963
|
+
...FACETS,
|
|
964
|
+
options: FACETS.options.map((option) =>
|
|
965
|
+
option.key === 'colour'
|
|
966
|
+
? { ...option, values: option.values.map((value) => ({ ...value, count: 77 })) }
|
|
967
|
+
: option
|
|
968
|
+
),
|
|
969
|
+
};
|
|
970
|
+
const legends = (wrapper: VueWrapper, root: 'aside' | 'dialog') =>
|
|
971
|
+
wrapper
|
|
972
|
+
.get(root)
|
|
973
|
+
.findAll('legend')
|
|
974
|
+
.map((legend) => legend.text());
|
|
975
|
+
|
|
976
|
+
async function narrowThenOpenDrawer(stub: Stub) {
|
|
977
|
+
useFilterTimers();
|
|
978
|
+
const wrapper = mountGrid(mock, { source: stub.source, attachTo: document.body });
|
|
979
|
+
await wrapper.vm.$nextTick();
|
|
980
|
+
await panelFor(wrapper, enUS.grid.legendSize)
|
|
981
|
+
.panel.findAll('input[type="checkbox"]')[2]!
|
|
982
|
+
.setValue(true);
|
|
983
|
+
await settleFilterDebounce(wrapper);
|
|
984
|
+
expect(legends(wrapper, 'aside')).not.toContain(enUS.grid.legendColour);
|
|
985
|
+
|
|
986
|
+
await filterButton(wrapper).trigger('click');
|
|
987
|
+
await wrapper.vm.$nextTick();
|
|
988
|
+
return wrapper;
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
/** The drawer's own Size group: the tick that narrowed the page, now pending. */
|
|
992
|
+
const untickSizeInDrawer = async (wrapper: VueWrapper) => {
|
|
993
|
+
useFilterTimers();
|
|
994
|
+
const sizes = wrapper
|
|
995
|
+
.get('dialog')
|
|
996
|
+
.findAll('fieldset')
|
|
997
|
+
.find((group) => group.get('legend').text() === enUS.grid.legendSize)!;
|
|
998
|
+
await sizes.findAll('input[type="checkbox"]')[2]!.setValue(false);
|
|
999
|
+
await settleFilterDebounce(wrapper);
|
|
1000
|
+
await flushPromises();
|
|
1001
|
+
};
|
|
1002
|
+
|
|
1003
|
+
it('brings back a group the applied facets lack, counted from the pending read', async () => {
|
|
1004
|
+
const stub = createStub(PRODUCTS, {
|
|
1005
|
+
filteredCount: 4,
|
|
1006
|
+
filteredFacets: withoutColour,
|
|
1007
|
+
facets: withColour,
|
|
1008
|
+
});
|
|
1009
|
+
const wrapper = await narrowThenOpenDrawer(stub);
|
|
1010
|
+
// Nothing pending differs yet, so the drawer describes the same narrowed result.
|
|
1011
|
+
expect(legends(wrapper, 'dialog')).not.toContain(enUS.grid.legendColour);
|
|
1012
|
+
|
|
1013
|
+
await untickSizeInDrawer(wrapper);
|
|
1014
|
+
|
|
1015
|
+
expect(legends(wrapper, 'dialog')).toContain(enUS.grid.legendColour);
|
|
1016
|
+
expect(wrapper.get('dialog').text()).toContain('77');
|
|
1017
|
+
// The page behind it is untouched, and its sidebar still reads the applied facets.
|
|
1018
|
+
expect(legends(wrapper, 'aside')).not.toContain(enUS.grid.legendColour);
|
|
1019
|
+
expect(countLine(wrapper).text()).toBe('4 products');
|
|
1020
|
+
});
|
|
1021
|
+
|
|
1022
|
+
it('keeps a group the pending selection holds even when the pending facets stop listing it', async () => {
|
|
1023
|
+
useFilterTimers();
|
|
1024
|
+
const stub = createStub(PRODUCTS, { filteredCount: 4, filteredFacets: withoutColour });
|
|
1025
|
+
const wrapper = mountGrid(mock, { source: stub.source, attachTo: document.body });
|
|
1026
|
+
await wrapper.vm.$nextTick();
|
|
1027
|
+
await panelFor(wrapper, enUS.grid.legendColour)
|
|
1028
|
+
.panel.get('input[type="checkbox"]')
|
|
1029
|
+
.setValue(true);
|
|
1030
|
+
await settleFilterDebounce(wrapper);
|
|
1031
|
+
|
|
1032
|
+
await filterButton(wrapper).trigger('click');
|
|
1033
|
+
await flushPromises();
|
|
1034
|
+
|
|
1035
|
+
expect(legends(wrapper, 'dialog')).toContain(enUS.grid.legendColour);
|
|
1036
|
+
});
|
|
1037
|
+
|
|
1038
|
+
it('shows the applied facets until the pending read has answered', async () => {
|
|
1039
|
+
const stub = createStub(PRODUCTS, {
|
|
1040
|
+
filteredCount: 4,
|
|
1041
|
+
filteredFacets: withoutColour,
|
|
1042
|
+
facets: withColour,
|
|
1043
|
+
});
|
|
1044
|
+
stub.holdCountReads.value = true;
|
|
1045
|
+
const wrapper = await narrowThenOpenDrawer(stub);
|
|
1046
|
+
expect(legends(wrapper, 'dialog')).toContain(enUS.grid.legendSize);
|
|
1047
|
+
|
|
1048
|
+
await untickSizeInDrawer(wrapper);
|
|
1049
|
+
expect(legends(wrapper, 'dialog')).not.toContain(enUS.grid.legendColour);
|
|
1050
|
+
|
|
1051
|
+
stub.holdCountReads.value = false;
|
|
1052
|
+
await flushPromises();
|
|
1053
|
+
expect(legends(wrapper, 'dialog')).toContain(enUS.grid.legendColour);
|
|
1054
|
+
});
|
|
1055
|
+
});
|
|
1056
|
+
|
|
943
1057
|
describe('the active filters', () => {
|
|
944
1058
|
it('lists a removable chip per selected value, named with its group', async () => {
|
|
945
1059
|
const wrapper = mountGrid(mock);
|
|
@@ -1670,7 +1784,7 @@ describe('collection-grid block', () => {
|
|
|
1670
1784
|
// into an explicit `option:size` row gets that label in both locales, since a string a
|
|
1671
1785
|
// merchant wrote is not the theme's to translate.)
|
|
1672
1786
|
expect(removeLabel()).toBe(`Fjarlægja síu ${isIS.grid.legendSize}: M`);
|
|
1673
|
-
expect(loadMoreLine()).toContain('
|
|
1787
|
+
expect(loadMoreLine()).toContain('12 af 12');
|
|
1674
1788
|
expect(countLine(wrapper).text()).toBe(isIS.grid.nProducts.replace('{count}', '12'));
|
|
1675
1789
|
});
|
|
1676
1790
|
});
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -316,6 +316,7 @@ const showNewsletter = computed(
|
|
|
316
316
|
);
|
|
317
317
|
// Only a footer that shows the sign-up reads the form's definition (its honeypot and Turnstile).
|
|
318
318
|
const {
|
|
319
|
+
definition,
|
|
319
320
|
honeypot,
|
|
320
321
|
honeypotField,
|
|
321
322
|
siteKey,
|
|
@@ -326,6 +327,11 @@ const {
|
|
|
326
327
|
reset,
|
|
327
328
|
} = useFormSpam(computed(() => (showNewsletter.value ? NEWSLETTER_FORM_KEY : '')));
|
|
328
329
|
const consentSentenceId = `footer-consent-sentence-${useUiId()}`;
|
|
330
|
+
// The merchant's own label and placeholder on the form's email field; the theme's wording stands in until the
|
|
331
|
+
// definition has loaded.
|
|
332
|
+
const emailField = computed(() => definition.value?.fields.find((field) => field.type === 'email'));
|
|
333
|
+
const emailLabel = computed(() => emailField.value?.label || t('footer.emailLabel'));
|
|
334
|
+
const emailPlaceholder = computed(() => emailField.value?.placeholder || undefined);
|
|
329
335
|
|
|
330
336
|
/** Mirrors `blocks/newsletter/Block.vue`'s own comment: an error has to clear itself the moment
|
|
331
337
|
* its own condition is fixed (the visitor edits the address), not only inside a later successful
|
|
@@ -521,6 +527,7 @@ async function onNewsletterSubmit(payload: FormLayoutSubmitPayload): Promise<voi
|
|
|
521
527
|
:heading-level="3"
|
|
522
528
|
:aria-label="data.newsletterTitle ? undefined : t('footer.newsletterAriaLabel')"
|
|
523
529
|
:submitting="newsletterState === 'submitting'"
|
|
530
|
+
:classes="{ actions: 'w-full mt-3' }"
|
|
524
531
|
@submit="onNewsletterSubmit"
|
|
525
532
|
@invalid="onNewsletterInvalid"
|
|
526
533
|
>
|
|
@@ -532,23 +539,23 @@ async function onNewsletterSubmit(payload: FormLayoutSubmitPayload): Promise<voi
|
|
|
532
539
|
</p>
|
|
533
540
|
<div ref="emailFieldRoot" class="contents">
|
|
534
541
|
<FieldWrapper
|
|
535
|
-
:label="
|
|
542
|
+
:label="emailLabel"
|
|
536
543
|
:error="emailError ?? undefined"
|
|
537
|
-
:classes="{
|
|
544
|
+
:classes="{ root: 'block w-full' }"
|
|
538
545
|
>
|
|
539
546
|
<Input
|
|
540
547
|
v-model="email"
|
|
541
548
|
type="email"
|
|
542
549
|
name="email"
|
|
543
550
|
autocomplete="email"
|
|
544
|
-
:placeholder="
|
|
551
|
+
:placeholder="emailPlaceholder"
|
|
545
552
|
/>
|
|
546
553
|
</FieldWrapper>
|
|
547
554
|
</div>
|
|
548
555
|
<FormHoneypot v-model="honeypot" :name="honeypotField" />
|
|
549
556
|
<div v-if="siteKey" ref="turnstileRoot" class="w-full" />
|
|
550
557
|
<template #actions>
|
|
551
|
-
<div class="grid w-full gap-2">
|
|
558
|
+
<div class="grid w-full grid-cols-[minmax(0,1fr)] gap-2">
|
|
552
559
|
<Button
|
|
553
560
|
type="submit"
|
|
554
561
|
variant="primary"
|