@eldrajs/theme-cli 0.2.8 → 0.2.9
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/CHANGELOG.md +2 -1
- package/package.json +1 -1
- package/template/.eldra/block-types.d.ts +28 -7
- package/template/.eldra/manifest.json +1034 -355
- package/template/.eldra/previews.json +35 -35
- package/template/README.md +32 -0
- package/template/app/assets/main.css +23 -0
- package/template/app/plugins/eldra-storefront.ts +3 -0
- package/template/app/storefront/demo.ts +75 -24
- package/template/app/storefront/gateway.ts +16 -2
- package/template/blocks/announcement-bar/preview.png +0 -0
- package/template/blocks/article/preview.json +4 -4
- package/template/blocks/article/preview.png +0 -0
- package/template/blocks/article-list/Block.vue +48 -19
- package/template/blocks/article-list/__tests__/Block.spec.ts +15 -0
- package/template/blocks/article-list/preview.json +43 -43
- 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 +260 -9
- package/template/blocks/collection-grid/__tests__/Block.spec.ts +202 -0
- package/template/blocks/collection-grid/block.json +3 -3
- package/template/blocks/collection-grid/preview.png +0 -0
- package/template/blocks/collection-header/Block.vue +65 -52
- package/template/blocks/collection-header/preview.json +4 -4
- package/template/blocks/collection-header/preview.png +0 -0
- package/template/blocks/contact/preview.png +0 -0
- package/template/blocks/cta/preview.json +4 -4
- package/template/blocks/cta/preview.png +0 -0
- package/template/blocks/faq/preview.png +0 -0
- package/template/blocks/feature-grid/Block.vue +73 -4
- package/template/blocks/feature-grid/__tests__/Block.spec.ts +43 -1
- package/template/blocks/feature-grid/block.json +2 -2
- package/template/blocks/feature-grid/preview.json +49 -24
- package/template/blocks/feature-grid/preview.png +0 -0
- package/template/blocks/footer/Block.vue +186 -71
- package/template/blocks/footer/__tests__/Block.spec.ts +127 -32
- package/template/blocks/footer/block.json +42 -4
- package/template/blocks/footer/mock.json +31 -34
- package/template/blocks/footer/preview.png +0 -0
- package/template/blocks/form/preview.png +0 -0
- package/template/blocks/gallery/preview.json +24 -24
- package/template/blocks/gallery/preview.png +0 -0
- package/template/blocks/hero/Block.vue +117 -19
- package/template/blocks/hero/__tests__/Block.spec.ts +46 -0
- package/template/blocks/hero/block.json +36 -1
- package/template/blocks/hero/preview.json +33 -25
- package/template/blocks/hero/preview.png +0 -0
- package/template/blocks/image/preview.json +4 -4
- package/template/blocks/image/preview.png +0 -0
- package/template/blocks/logo-cloud/preview.png +0 -0
- package/template/blocks/navigation/Block.vue +622 -184
- package/template/blocks/navigation/__tests__/Block.spec.ts +406 -68
- package/template/blocks/navigation/__tests__/fixtures/menu.json +182 -0
- package/template/blocks/navigation/block.json +102 -6
- package/template/blocks/navigation/mock.json +279 -52
- package/template/blocks/navigation/preview.json +311 -0
- package/template/blocks/navigation/preview.png +0 -0
- package/template/blocks/newsletter/Block.vue +248 -144
- package/template/blocks/newsletter/__tests__/Block.spec.ts +42 -0
- package/template/blocks/newsletter/block.json +61 -2
- package/template/blocks/newsletter/preview.json +35 -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/Block.vue +272 -26
- package/template/blocks/product-carousel/__tests__/Block.spec.ts +90 -0
- package/template/blocks/product-carousel/block.json +61 -0
- package/template/blocks/product-carousel/preview.json +12 -0
- package/template/blocks/product-carousel/preview.png +0 -0
- package/template/blocks/product-detail/Block.vue +148 -96
- package/template/blocks/product-detail/__tests__/Block.spec.ts +98 -74
- package/template/blocks/product-detail/block.json +11 -4
- package/template/blocks/product-detail/mock.json +53 -22
- package/template/blocks/product-detail/parts/Gallery.vue +52 -103
- 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/Block.vue +1 -0
- package/template/blocks/search/TypeSection.vue +1 -0
- package/template/blocks/search/__tests__/Block.spec.ts +23 -0
- package/template/blocks/search/preview.png +0 -0
- package/template/blocks/split-content/Block.vue +98 -20
- package/template/blocks/split-content/__tests__/Block.spec.ts +57 -18
- package/template/blocks/split-content/block.json +72 -6
- package/template/blocks/split-content/preview.json +34 -13
- package/template/blocks/split-content/preview.png +0 -0
- package/template/blocks/stats/preview.png +0 -0
- package/template/blocks/tabs/preview.json +16 -16
- 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/Block.vue +67 -1
- package/template/blocks/trust-strip/__tests__/Block.spec.ts +30 -1
- package/template/blocks/trust-strip/block.json +4 -4
- package/template/blocks/trust-strip/preview.json +21 -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/i18n/en-US.json +16 -9
- package/template/i18n/is-IS.json +16 -9
- package/template/pages/article.page.json +19 -18
- package/template/pages/cart.page.json +3 -13
- package/template/pages/category.page.json +15 -7
- package/template/pages/collection.page.json +15 -14
- package/template/pages/home.page.json +217 -182
- package/template/pages/product.page.json +46 -36
- package/template/pages/products.page.json +3 -13
- package/template/pages/search.page.json +3 -13
- package/template/pages/wishlist.page.json +3 -13
- package/template/public/images/CREDITS.md +28 -0
- package/template/public/images/clay-hands.webp +0 -0
- package/template/public/images/coffee-table.webp +0 -0
- package/template/public/images/cup.webp +0 -0
- package/template/public/images/enamel-cups.webp +0 -0
- package/template/public/images/hero.webp +0 -0
- package/template/public/images/kitchen.webp +0 -0
- package/template/public/images/mug.webp +0 -0
- package/template/public/images/northwind-mark.svg +1 -0
- package/template/public/images/planters.webp +0 -0
- package/template/public/images/plates.webp +0 -0
- package/template/public/images/reading.webp +0 -0
- package/template/public/images/sweater.webp +0 -0
- package/template/public/images/terracotta.webp +0 -0
- package/template/public/images/throws.webp +0 -0
- package/template/public/images/vase.webp +0 -0
- package/template/public/images/wheel.webp +0 -0
- package/template/public/images/yarn-tools.webp +0 -0
- package/template/public/images/yarn.webp +0 -0
- package/template/stories/generated/collection-grid.stories.ts +6 -0
- package/template/stories/generated/feature-grid.stories.ts +6 -0
- package/template/stories/generated/footer.stories.ts +4 -4
- package/template/stories/generated/hero.stories.ts +6 -0
- package/template/stories/generated/navigation.stories.ts +14 -1
- package/template/stories/generated/newsletter.stories.ts +2 -1
- package/template/stories/generated/product-carousel.stories.ts +12 -0
- package/template/stories/generated/split-content.stories.ts +12 -0
- package/template/stories/generated/trust-strip.stories.ts +8 -1
- package/template/stories/pages/article.stories.ts +2 -1
- package/template/stories/pages/cart.stories.ts +2 -1
- package/template/stories/pages/category.stories.ts +2 -1
- package/template/stories/pages/collection.stories.ts +2 -1
- package/template/stories/pages/home.stories.ts +2 -1
- package/template/stories/pages/product.stories.ts +2 -1
- package/template/stories/pages/products.stories.ts +2 -1
- package/template/stories/pages/search.stories.ts +2 -1
- package/template/stories/pages/wishlist.stories.ts +2 -1
- package/template/stories/support/demoChrome.ts +32 -0
- package/template/stories/support/pageBlocks.ts +2 -4
- package/template/test/countPill.browser.spec.ts +21 -13
- package/template/test/localePrefix.spec.ts +11 -6
- package/template/test/pages/article.spec.ts +1 -1
- package/template/test/pages/category.spec.ts +34 -11
- package/template/test/pages/collection.spec.ts +182 -148
- package/template/test/pages/home.spec.ts +35 -40
- package/template/test/pages/hydration.spec.ts +4 -4
- package/template/test/pages/product.spec.ts +17 -14
- package/template/test/pages/seededPages.spec.ts +11 -6
- package/template/test/prerenderRefresh.browser.spec.ts +36 -15
- package/template/test/starter.spec.ts +31 -15
- package/template/test/storefront/gatewayPrerender.spec.ts +26 -0
- package/template/tokens.json +13 -13
|
@@ -1,51 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"items": [
|
|
3
3
|
{
|
|
4
|
-
"title": "
|
|
5
|
-
"dek": "
|
|
6
|
-
"href": "/journal/
|
|
7
|
-
"categoryLabel": "
|
|
8
|
-
"categoryHref": "/journal/
|
|
9
|
-
"publishedAt": "2026-
|
|
10
|
-
"readingTime": "
|
|
4
|
+
"title": "Five small rituals for a slower morning coffee",
|
|
5
|
+
"dek": "Warm the cup, grind by hand, sit down to drink it. Small habits that make the first ten minutes of the day your own.",
|
|
6
|
+
"href": "/journal/slower-morning-coffee",
|
|
7
|
+
"categoryLabel": "At home",
|
|
8
|
+
"categoryHref": "/journal/home",
|
|
9
|
+
"publishedAt": "2026-10-02",
|
|
10
|
+
"readingTime": "4 min read",
|
|
11
11
|
"image": {
|
|
12
|
-
"assetId": "demo-
|
|
13
|
-
"url": "/
|
|
14
|
-
"altText": "",
|
|
15
|
-
"width":
|
|
16
|
-
"height":
|
|
12
|
+
"assetId": "demo-journal-1",
|
|
13
|
+
"url": "/images/coffee-table.webp",
|
|
14
|
+
"altText": "A polka-dot mug of coffee with biscuits and reading glasses",
|
|
15
|
+
"width": 1400,
|
|
16
|
+
"height": 933
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
|
-
"title": "
|
|
21
|
-
"dek": "
|
|
22
|
-
"href": "/journal/
|
|
23
|
-
"categoryLabel": "
|
|
24
|
-
"categoryHref": "/journal/
|
|
25
|
-
"publishedAt": "2026-09-
|
|
26
|
-
"readingTime": "
|
|
20
|
+
"title": "A morning at the wheel with Harbour Pottery",
|
|
21
|
+
"dek": "Six pairs of hands, two firings and a kiln that always has the last word. We spent a morning in the studio.",
|
|
22
|
+
"href": "/journal/harbour-pottery",
|
|
23
|
+
"categoryLabel": "Workshop visit",
|
|
24
|
+
"categoryHref": "/journal/makers",
|
|
25
|
+
"publishedAt": "2026-09-24",
|
|
26
|
+
"readingTime": "6 min read",
|
|
27
27
|
"image": {
|
|
28
|
-
"assetId": "demo-
|
|
29
|
-
"url": "/
|
|
30
|
-
"altText": "",
|
|
31
|
-
"width":
|
|
32
|
-
"height":
|
|
28
|
+
"assetId": "demo-journal-2",
|
|
29
|
+
"url": "/images/clay-hands.webp",
|
|
30
|
+
"altText": "A potter's hands working wet clay",
|
|
31
|
+
"width": 1400,
|
|
32
|
+
"height": 933
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
{
|
|
36
|
-
"title": "
|
|
37
|
-
"dek": "
|
|
38
|
-
"href": "/journal/
|
|
39
|
-
"categoryLabel": "
|
|
40
|
-
"categoryHref": "/journal/
|
|
41
|
-
"publishedAt": "2026-
|
|
36
|
+
"title": "Layering throws for a colder season",
|
|
37
|
+
"dek": "Wool over linen, heavy over light: how to build a sofa corner that keeps you warm from October to April.",
|
|
38
|
+
"href": "/journal/layering-throws",
|
|
39
|
+
"categoryLabel": "Knitting",
|
|
40
|
+
"categoryHref": "/journal/care",
|
|
41
|
+
"publishedAt": "2026-09-12",
|
|
42
42
|
"readingTime": "3 min read",
|
|
43
43
|
"image": {
|
|
44
|
-
"assetId": "demo-
|
|
45
|
-
"url": "/
|
|
46
|
-
"altText": "",
|
|
47
|
-
"width":
|
|
48
|
-
"height":
|
|
44
|
+
"assetId": "demo-journal-3",
|
|
45
|
+
"url": "/images/throws.webp",
|
|
46
|
+
"altText": "Folded knitted throws in green and grey",
|
|
47
|
+
"width": 1400,
|
|
48
|
+
"height": 910
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
{
|
|
@@ -58,10 +58,10 @@
|
|
|
58
58
|
"readingTime": "7 min read",
|
|
59
59
|
"image": {
|
|
60
60
|
"assetId": "demo-gallery-4",
|
|
61
|
-
"url": "/
|
|
62
|
-
"altText": "",
|
|
63
|
-
"width":
|
|
64
|
-
"height":
|
|
61
|
+
"url": "/images/coffee-table.webp",
|
|
62
|
+
"altText": "A polka-dot mug of coffee with biscuits",
|
|
63
|
+
"width": 1400,
|
|
64
|
+
"height": 933
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
67
|
{
|
|
@@ -74,10 +74,10 @@
|
|
|
74
74
|
"readingTime": "5 min read",
|
|
75
75
|
"image": {
|
|
76
76
|
"assetId": "demo-gallery-5",
|
|
77
|
-
"url": "/
|
|
78
|
-
"altText": "",
|
|
79
|
-
"width":
|
|
80
|
-
"height":
|
|
77
|
+
"url": "/images/terracotta.webp",
|
|
78
|
+
"altText": "Handmade terracotta bowls and jugs",
|
|
79
|
+
"width": 1400,
|
|
80
|
+
"height": 933
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
]
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* Collection grid: a collection's products as a filterable, sortable card grid — a sticky filter
|
|
4
4
|
* sidebar from 64rem of the block's own width, a filter drawer below that (and at every width in
|
|
5
5
|
* `drawer-only`) (spec `02-blocks.md` "Collection grid", 3047–3170, over the shared "Product grid"
|
|
6
|
-
* and "Progress bar" parts at 3036–3045)
|
|
6
|
+
* and "Progress bar" parts at 3036–3045) — or, in `filter-bar`, one horizontal row of filter chips
|
|
7
|
+
* above the grid with the applied filters as removable tags under it (see `isBar`).
|
|
7
8
|
*
|
|
8
9
|
* **Where the data comes from.** Everything a shopper sees — cards, prices, filter values, counts,
|
|
9
10
|
* the total — is `useStorefront().catalog.collectionProducts()`; the CMS fields only configure the
|
|
@@ -53,6 +54,7 @@ import {
|
|
|
53
54
|
import {
|
|
54
55
|
Badge,
|
|
55
56
|
Button,
|
|
57
|
+
Chip,
|
|
56
58
|
Container,
|
|
57
59
|
Drawer,
|
|
58
60
|
EditorPlaceholder,
|
|
@@ -61,6 +63,7 @@ import {
|
|
|
61
63
|
FilterPanel,
|
|
62
64
|
LoadMore,
|
|
63
65
|
Pagination,
|
|
66
|
+
Popover,
|
|
64
67
|
ProductCard,
|
|
65
68
|
Section,
|
|
66
69
|
Select,
|
|
@@ -72,6 +75,7 @@ import {
|
|
|
72
75
|
type FilterFacetLayout,
|
|
73
76
|
type FilterSelection as UiFilterSelection,
|
|
74
77
|
type SelectOption,
|
|
78
|
+
type UiMessages,
|
|
75
79
|
} from '@eldrajs/ui';
|
|
76
80
|
import { useEldraLink } from '@eldrajs/theme-vue';
|
|
77
81
|
import { useBlockData } from '../../app/composables/useBlockData';
|
|
@@ -81,6 +85,7 @@ import { useRevalidating } from '../../app/composables/useRevalidating';
|
|
|
81
85
|
import { useStorefront } from '../../app/composables/useStorefront';
|
|
82
86
|
import { useI18n } from 'vue-i18n';
|
|
83
87
|
import { useUiId } from '../../app/composables/useUiId';
|
|
88
|
+
import EldraIcon from '../../app/components/EldraIcon.vue';
|
|
84
89
|
import EldraRouterLink from '../../app/components/EldraRouterLink.vue';
|
|
85
90
|
import { toProductCardEntries } from '../../app/storefront/toProductCard';
|
|
86
91
|
import { useMoney } from '../../app/storefront/money';
|
|
@@ -167,11 +172,24 @@ const filterPanelMessages = useMessages();
|
|
|
167
172
|
* visually hidden `h2` 'Products'"). */
|
|
168
173
|
const productsHeadingId = `collection-grid-products-${uid}`;
|
|
169
174
|
|
|
170
|
-
type Variant = 'sidebar' | 'drawer-only';
|
|
175
|
+
type Variant = 'sidebar' | 'drawer-only' | 'filter-bar';
|
|
171
176
|
const variant = computed<Variant>(() =>
|
|
172
|
-
data.value.variant === 'drawer-only'
|
|
177
|
+
data.value.variant === 'drawer-only'
|
|
178
|
+
? 'drawer-only'
|
|
179
|
+
: data.value.variant === 'filter-bar'
|
|
180
|
+
? 'filter-bar'
|
|
181
|
+
: 'sidebar'
|
|
173
182
|
);
|
|
174
183
|
const hasSidebar = computed(() => variant.value === 'sidebar');
|
|
184
|
+
/**
|
|
185
|
+
* **`filter-bar`**: one horizontal row of filter chips above the grid instead of a sidebar or a
|
|
186
|
+
* drawer — a chip per group that opens that group's own `FilterPanel` in a `Popover`, a pressed chip
|
|
187
|
+
* per on/off value (In stock only), and the sort on the far end — with the applied filters as
|
|
188
|
+
* removable tags under it beside the count. Only the **layout** differs: every change goes through
|
|
189
|
+
* the sidebar's own live path (`onPanelChange` and its debounce, `onPanelRemove`'s focus rule,
|
|
190
|
+
* `onClearAll`), so the requests, the URL and the results are exactly the sidebar variant's.
|
|
191
|
+
*/
|
|
192
|
+
const isBar = computed(() => variant.value === 'filter-bar');
|
|
175
193
|
|
|
176
194
|
/** The column counts the field, the Select and a shared URL all agree on. */
|
|
177
195
|
const COLUMN_CHOICES = ['2', '3', '4'];
|
|
@@ -1358,8 +1376,11 @@ async function onClearAll(): Promise<void> {
|
|
|
1358
1376
|
* for the Nth remove button in document order is exactly what a shopper's or a screen reader's own
|
|
1359
1377
|
* next stop would be, and does not depend on that internal bookkeeping.
|
|
1360
1378
|
*/
|
|
1361
|
-
function focusNthRemoveButton(
|
|
1362
|
-
|
|
1379
|
+
function focusNthRemoveButton(
|
|
1380
|
+
panel: InstanceType<typeof FilterPanel> | Element | null,
|
|
1381
|
+
index: number
|
|
1382
|
+
): void {
|
|
1383
|
+
const root = panel instanceof Element ? panel : (panel as { $el?: Element } | null)?.$el;
|
|
1363
1384
|
const button = root?.querySelectorAll('[data-part="removeButton"]')[index];
|
|
1364
1385
|
(button as HTMLElement | undefined)?.focus();
|
|
1365
1386
|
}
|
|
@@ -1382,9 +1403,98 @@ async function onPanelRemove(removal: { facetId: string; value: string }): Promi
|
|
|
1382
1403
|
focusCount();
|
|
1383
1404
|
return;
|
|
1384
1405
|
}
|
|
1385
|
-
focusNthRemoveButton(
|
|
1406
|
+
focusNthRemoveButton(
|
|
1407
|
+
isBar.value ? barTagsEl.value : sidebarPanelEl.value,
|
|
1408
|
+
Math.min(index, remaining.length - 1)
|
|
1409
|
+
);
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
// ---------------------------------------------------------------------------------------------
|
|
1413
|
+
// The filter bar (`filter-bar` only)
|
|
1414
|
+
// ---------------------------------------------------------------------------------------------
|
|
1415
|
+
|
|
1416
|
+
/** The bar's applied-filter tags, for `onPanelRemove`'s "focus the next tag" rule. */
|
|
1417
|
+
const barTagsEl = ref<HTMLElement | null>(null);
|
|
1418
|
+
|
|
1419
|
+
/** The applied values as tags — `@eldrajs/ui`'s own `appliedFilters`, the same list the sidebar
|
|
1420
|
+
* panel's chips are drawn from, so a range contributes none here either. */
|
|
1421
|
+
const barTags = computed(() => appliedFilters(filterFacets.value, panelSelection.value));
|
|
1422
|
+
|
|
1423
|
+
/** On/off groups (availability and the store's own toggles) are pressed chips in the bar itself;
|
|
1424
|
+
* every other group opens its own popover. */
|
|
1425
|
+
const barToggleFacets = computed(() =>
|
|
1426
|
+
filterFacets.value.filter((facet) => facet.type === 'toggle')
|
|
1427
|
+
);
|
|
1428
|
+
const barPopoverFacets = computed(() =>
|
|
1429
|
+
filterFacets.value.filter((facet) => facet.type !== 'toggle')
|
|
1430
|
+
);
|
|
1431
|
+
|
|
1432
|
+
/** A popover holds one group, open: the facet's own "Start closed" belongs to a list of groups,
|
|
1433
|
+
* and a popover the shopper just asked for showing a collapsed group would be one click too many. */
|
|
1434
|
+
function popoverFacets(facet: FilterFacet): FilterFacet[] {
|
|
1435
|
+
return [{ ...facet, collapsed: false }];
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
function selectedIn(facetId: string): string[] {
|
|
1439
|
+
const value = panelSelection.value[facetId];
|
|
1440
|
+
return Array.isArray(value) && typeof value[0] !== 'number' ? (value as string[]) : [];
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
/** The digit beside a chip: checked values, or 1 for a price range away from its limits. */
|
|
1444
|
+
function barCount(facet: FilterFacet): number {
|
|
1445
|
+
if (facet.type === 'range') return priceMin.value !== '' || priceMax.value !== '' ? 1 : 0;
|
|
1446
|
+
return selectedIn(facet.id).length;
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
function isBarValuePressed(facetId: string, value: string): boolean {
|
|
1450
|
+
return selectedIn(facetId).includes(value);
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
/** A pressed chip is one checkbox of its group: the whole resulting selection goes through the
|
|
1454
|
+
* sidebar's live path, as the panel's own `change` does. */
|
|
1455
|
+
function toggleBarValue(facetId: string, value: string): void {
|
|
1456
|
+
const current = selectedIn(facetId);
|
|
1457
|
+
const nextValues = current.includes(value)
|
|
1458
|
+
? current.filter((entry) => entry !== value)
|
|
1459
|
+
: [...current, value];
|
|
1460
|
+
const next: UiFilterSelection = { ...panelSelection.value };
|
|
1461
|
+
if (nextValues.length > 0) next[facetId] = nextValues;
|
|
1462
|
+
else delete next[facetId];
|
|
1463
|
+
onPanelChange(next);
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
/** A tag's remove button: the panel's own chip removal, replayed — `change` with the value gone,
|
|
1467
|
+
* then `remove`, which flushes and moves focus to the next tag or the count. */
|
|
1468
|
+
function removeBarTag(tag: { facetId: string; value: string }): void {
|
|
1469
|
+
const nextValues = selectedIn(tag.facetId).filter((entry) => entry !== tag.value);
|
|
1470
|
+
const next: UiFilterSelection = { ...panelSelection.value };
|
|
1471
|
+
if (nextValues.length > 0) next[tag.facetId] = nextValues;
|
|
1472
|
+
else delete next[tag.facetId];
|
|
1473
|
+
onPanelChange(next);
|
|
1474
|
+
void onPanelRemove({ facetId: tag.facetId, value: tag.value });
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
function barTagMessages(tag: { facetLabel: string; label: string }): Partial<UiMessages> {
|
|
1478
|
+
return {
|
|
1479
|
+
removeTag: () => filterPanelMessages.value.filterPanelRemoveFilter(tag.facetLabel, tag.label),
|
|
1480
|
+
};
|
|
1386
1481
|
}
|
|
1387
1482
|
|
|
1483
|
+
/** The Northwind chip: outlined, 2.5rem, filled with `text` while pressed or open. Exclusive
|
|
1484
|
+
* branches, so no class is ever overridden by another on the same element. */
|
|
1485
|
+
const BAR_CHIP_BASE =
|
|
1486
|
+
'eldra-focus inline-flex min-h-10 cursor-pointer items-center gap-1.5 whitespace-nowrap ' +
|
|
1487
|
+
'rounded-full border px-4 text-[0.9375rem] font-medium motion-safe:transition-colors ' +
|
|
1488
|
+
'motion-safe:duration-fast disabled:cursor-not-allowed disabled:opacity-50';
|
|
1489
|
+
const BAR_CHIP_ON = `${BAR_CHIP_BASE} bg-text text-background border-text`;
|
|
1490
|
+
const BAR_CHIP_OFF = `${BAR_CHIP_BASE} border-border-strong text-text hover:bg-surface`;
|
|
1491
|
+
const BAR_POPOVER_CLASSES = {
|
|
1492
|
+
panel: 'w-[20rem] max-w-[calc(100vw-2rem)] max-h-[min(30rem,70vh)] overflow-y-auto px-4 pb-2',
|
|
1493
|
+
};
|
|
1494
|
+
/** The group's own disclosure row reads as the popover's heading; its rules are the popover's
|
|
1495
|
+
* border already. */
|
|
1496
|
+
const BAR_PANEL_CLASSES = { group: 'border-0', foot: 'hidden' };
|
|
1497
|
+
|
|
1388
1498
|
/** Widen the window first, resolve an armed sidebar wait second — the ordering `onColumns` explains
|
|
1389
1499
|
* at length. Flushing first assigned the mirror on the old window, and the wider one that followed
|
|
1390
1500
|
* queued the mirror behind the result's own watcher: two reads for one press, the first of them
|
|
@@ -1668,8 +1778,146 @@ function hrefForPage(page: number): string {
|
|
|
1668
1778
|
</aside>
|
|
1669
1779
|
|
|
1670
1780
|
<div class="min-w-0">
|
|
1781
|
+
<!-- The filter bar (`filter-bar`): a chip per group, the pressed on/off chips and the
|
|
1782
|
+
sort, one row that wraps on a narrow screen and stays in view while the grid
|
|
1783
|
+
scrolls from 48rem. -->
|
|
1784
|
+
<template v-if="isBar">
|
|
1785
|
+
<div
|
|
1786
|
+
v-if="showTopBar"
|
|
1787
|
+
role="group"
|
|
1788
|
+
:aria-label="t('grid.filterAndSort')"
|
|
1789
|
+
class="border-border bg-background @tablet:sticky @tablet:top-[var(--eldra-header-height,0px)] @tablet:z-10 flex flex-wrap items-center gap-2 border-y py-3.5"
|
|
1790
|
+
>
|
|
1791
|
+
<Popover
|
|
1792
|
+
v-for="facet in barPopoverFacets"
|
|
1793
|
+
:key="facet.id"
|
|
1794
|
+
role="dialog"
|
|
1795
|
+
haspopup="dialog"
|
|
1796
|
+
placement="bottom-start"
|
|
1797
|
+
:aria-label="facet.label"
|
|
1798
|
+
:classes="BAR_POPOVER_CLASSES"
|
|
1799
|
+
>
|
|
1800
|
+
<template #trigger="{ attrs, open }">
|
|
1801
|
+
<button v-bind="attrs" :class="open ? BAR_CHIP_ON : BAR_CHIP_OFF">
|
|
1802
|
+
{{ facet.label }}
|
|
1803
|
+
<Badge
|
|
1804
|
+
v-if="barCount(facet) > 0"
|
|
1805
|
+
tone="primary"
|
|
1806
|
+
pill
|
|
1807
|
+
:hidden-suffix="t('grid.nActive', { count: barCount(facet) })"
|
|
1808
|
+
>
|
|
1809
|
+
<span aria-hidden="true">{{ barCount(facet) }}</span>
|
|
1810
|
+
</Badge>
|
|
1811
|
+
<EldraIcon
|
|
1812
|
+
name="chevron-down"
|
|
1813
|
+
size="sm"
|
|
1814
|
+
:class="
|
|
1815
|
+
open
|
|
1816
|
+
? 'rotate-180 motion-safe:transition-transform'
|
|
1817
|
+
: 'motion-safe:transition-transform'
|
|
1818
|
+
"
|
|
1819
|
+
/>
|
|
1820
|
+
</button>
|
|
1821
|
+
</template>
|
|
1822
|
+
<FilterPanel
|
|
1823
|
+
mode="drawer"
|
|
1824
|
+
dense
|
|
1825
|
+
:show-head="false"
|
|
1826
|
+
:label="facet.label"
|
|
1827
|
+
:facets="popoverFacets(facet)"
|
|
1828
|
+
:model-value="panelSelection"
|
|
1829
|
+
:currency="money.currency.value"
|
|
1830
|
+
:id-prefix="`collection-grid-bar-${uid}-${facet.id}`"
|
|
1831
|
+
:classes="BAR_PANEL_CLASSES"
|
|
1832
|
+
@change="onPanelChange"
|
|
1833
|
+
>
|
|
1834
|
+
<template #foot><span /></template>
|
|
1835
|
+
</FilterPanel>
|
|
1836
|
+
</Popover>
|
|
1837
|
+
|
|
1838
|
+
<template v-for="facet in barToggleFacets" :key="facet.id">
|
|
1839
|
+
<button
|
|
1840
|
+
v-for="value in facet.values ?? []"
|
|
1841
|
+
:key="value.value"
|
|
1842
|
+
type="button"
|
|
1843
|
+
:aria-pressed="isBarValuePressed(facet.id, value.value) ? 'true' : 'false'"
|
|
1844
|
+
:disabled="value.disabled && !isBarValuePressed(facet.id, value.value)"
|
|
1845
|
+
:class="isBarValuePressed(facet.id, value.value) ? BAR_CHIP_ON : BAR_CHIP_OFF"
|
|
1846
|
+
@click="toggleBarValue(facet.id, value.value)"
|
|
1847
|
+
>
|
|
1848
|
+
{{ value.label }}
|
|
1849
|
+
</button>
|
|
1850
|
+
</template>
|
|
1851
|
+
|
|
1852
|
+
<div
|
|
1853
|
+
class="@tablet:ms-auto @tablet:w-auto flex w-full flex-wrap items-center gap-x-6 gap-y-2"
|
|
1854
|
+
>
|
|
1855
|
+
<FieldWrapper
|
|
1856
|
+
v-if="hasSort"
|
|
1857
|
+
:label="t('grid.sort')"
|
|
1858
|
+
class="flex min-w-0 flex-1 items-center gap-3"
|
|
1859
|
+
:classes="{ label: 'mb-0 shrink-0 font-semibold', control: 'min-w-0 flex-1' }"
|
|
1860
|
+
>
|
|
1861
|
+
<Select
|
|
1862
|
+
:model-value="sort"
|
|
1863
|
+
size="md"
|
|
1864
|
+
:options="sortOptions"
|
|
1865
|
+
class="@tablet:min-w-48 w-full"
|
|
1866
|
+
@update:model-value="onSort"
|
|
1867
|
+
/>
|
|
1868
|
+
</FieldWrapper>
|
|
1869
|
+
<FieldWrapper
|
|
1870
|
+
v-if="showColumnSelect"
|
|
1871
|
+
:label="t('grid.columns')"
|
|
1872
|
+
class="@content:flex hidden items-center gap-3"
|
|
1873
|
+
:classes="{ label: 'mb-0 shrink-0 font-semibold' }"
|
|
1874
|
+
>
|
|
1875
|
+
<Select
|
|
1876
|
+
:model-value="columnsChoice"
|
|
1877
|
+
size="md"
|
|
1878
|
+
:options="columnOptions"
|
|
1879
|
+
@update:model-value="onColumns"
|
|
1880
|
+
/>
|
|
1881
|
+
</FieldWrapper>
|
|
1882
|
+
</div>
|
|
1883
|
+
</div>
|
|
1884
|
+
|
|
1885
|
+
<!-- The count and the applied filters as removable tags, then Clear all. -->
|
|
1886
|
+
<div class="flex flex-wrap items-center gap-2 pt-4">
|
|
1887
|
+
<p
|
|
1888
|
+
ref="countEl"
|
|
1889
|
+
tabindex="-1"
|
|
1890
|
+
role="status"
|
|
1891
|
+
aria-live="polite"
|
|
1892
|
+
class="text-muted me-2 tabular-nums"
|
|
1893
|
+
>
|
|
1894
|
+
{{ countText }}
|
|
1895
|
+
</p>
|
|
1896
|
+
<ul
|
|
1897
|
+
v-if="barTags.length > 0"
|
|
1898
|
+
ref="barTagsEl"
|
|
1899
|
+
:aria-label="filterPanelMessages.filterPanelApplied"
|
|
1900
|
+
class="flex flex-wrap gap-2"
|
|
1901
|
+
>
|
|
1902
|
+
<li v-for="tag in barTags" :key="`${tag.facetId}:${tag.value}`">
|
|
1903
|
+
<Chip
|
|
1904
|
+
size="sm"
|
|
1905
|
+
removable
|
|
1906
|
+
:label="tag.label"
|
|
1907
|
+
:messages="barTagMessages(tag)"
|
|
1908
|
+
class="bg-surface-strong border-transparent"
|
|
1909
|
+
@remove="removeBarTag(tag)"
|
|
1910
|
+
/>
|
|
1911
|
+
</li>
|
|
1912
|
+
</ul>
|
|
1913
|
+
<Button v-if="activeCount > 0" variant="link" size="sm" @click="onClearAll">
|
|
1914
|
+
{{ filterPanelMessages.filterPanelClearAll }}
|
|
1915
|
+
</Button>
|
|
1916
|
+
</div>
|
|
1917
|
+
</template>
|
|
1918
|
+
|
|
1671
1919
|
<!-- Top bar: Filter + sort, below 64rem (always in drawer-only). -->
|
|
1672
|
-
<div v-if="showTopBar" :class="topBarClass">
|
|
1920
|
+
<div v-if="showTopBar && !isBar" :class="topBarClass">
|
|
1673
1921
|
<Button
|
|
1674
1922
|
v-if="hasFilters"
|
|
1675
1923
|
variant="outline"
|
|
@@ -1709,7 +1957,10 @@ function hrefForPage(page: number): string {
|
|
|
1709
1957
|
</div>
|
|
1710
1958
|
|
|
1711
1959
|
<!-- Toolbar: the count, and Sort by + Columns from 64rem. -->
|
|
1712
|
-
<div
|
|
1960
|
+
<div
|
|
1961
|
+
v-if="!isBar"
|
|
1962
|
+
class="border-border flex flex-wrap items-center gap-x-6 gap-y-2 border-b pb-4"
|
|
1963
|
+
>
|
|
1713
1964
|
<p
|
|
1714
1965
|
ref="countEl"
|
|
1715
1966
|
tabindex="-1"
|
|
@@ -1838,7 +2089,7 @@ function hrefForPage(page: number): string {
|
|
|
1838
2089
|
</div>
|
|
1839
2090
|
|
|
1840
2091
|
<Drawer
|
|
1841
|
-
v-if="hasFilters"
|
|
2092
|
+
v-if="hasFilters && !isBar"
|
|
1842
2093
|
:id="drawerId"
|
|
1843
2094
|
v-model="drawerOpen"
|
|
1844
2095
|
side="right"
|