acinguiux-preact-components 0.0.1
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 +56 -0
- package/src/content/themes/theme-acinguiux-amg/theme-acinguiux-amg.css +23 -0
- package/src/content/themes/theme-acinguiux-cafe/theme-acinguiux-cafe.css +47 -0
- package/src/content/themes/theme-acinguiux-energy/theme-acinguiux-energy.css +45 -0
- package/src/content/themes/theme-acinguiux-livewire/theme-acinguiux-livewire.css +22 -0
- package/src/content/themes/theme-acinguiux-livewire-italy/theme-acinguiux-livewire-italy.css +22 -0
- package/src/content/themes/theme-acinguiux-recharge/theme-acinguiux-recharge.css +49 -0
- package/src/content/themes/theme-allon/theme-allon.css +25 -0
- package/src/content/themes/theme-atlas/theme-atlas.css +31 -0
- package/src/content/themes/theme-aurvana/resources/favicon/apple-touch-icon.png +0 -0
- package/src/content/themes/theme-aurvana/resources/favicon/favico.ico +0 -0
- package/src/content/themes/theme-aurvana/resources/favicon/favicon-96x96.png +0 -0
- package/src/content/themes/theme-aurvana/resources/favicon/favicon.ico +0 -0
- package/src/content/themes/theme-aurvana/resources/favicon/favicon.png +0 -0
- package/src/content/themes/theme-aurvana/resources/favicon/favicon.svg +13 -0
- package/src/content/themes/theme-aurvana/resources/favicon/google-touch-icon.png +0 -0
- package/src/content/themes/theme-aurvana/resources/favicon/manifest.json +14 -0
- package/src/content/themes/theme-aurvana/resources/favicon/site.webmanifest +21 -0
- package/src/content/themes/theme-aurvana/resources/favicon/web-app-manifest-192x192.png +0 -0
- package/src/content/themes/theme-aurvana/resources/favicon/web-app-manifest-512x512.png +0 -0
- package/src/content/themes/theme-aurvana/theme-aurvana.css +49 -0
- package/src/content/themes/theme-base/theme-base.css +49 -0
- package/src/content/themes/theme-base2/resources/favicon/android-chrome-192x192.png +0 -0
- package/src/content/themes/theme-base2/resources/favicon/android-chrome-512x512.png +0 -0
- package/src/content/themes/theme-base2/resources/favicon/apple-touch-icon.png +0 -0
- package/src/content/themes/theme-base2/resources/favicon/favico.ico +0 -0
- package/src/content/themes/theme-base2/resources/favicon/favicon-16x16.png +0 -0
- package/src/content/themes/theme-base2/resources/favicon/favicon-32x32.png +0 -0
- package/src/content/themes/theme-base2/resources/favicon/favicon-96x96.png +0 -0
- package/src/content/themes/theme-base2/resources/favicon/favicon.ico +0 -0
- package/src/content/themes/theme-base2/resources/favicon/favicon.png +0 -0
- package/src/content/themes/theme-base2/resources/favicon/favicon.svg +9 -0
- package/src/content/themes/theme-base2/resources/favicon/google-touch-icon.png +0 -0
- package/src/content/themes/theme-base2/resources/favicon/manifest.json +14 -0
- package/src/content/themes/theme-base2/resources/favicon/site.webmanifest +1 -0
- package/src/content/themes/theme-base2/resources/favicon/web-app-manifest-192x192.png +0 -0
- package/src/content/themes/theme-base2/resources/favicon/web-app-manifest-512x512.png +0 -0
- package/src/content/themes/theme-base2/resources/fonts/acinguiux-typeface-la-heavy-221208.woff2 +0 -0
- package/src/content/themes/theme-base2/theme-base2.css +47 -0
- package/src/content/themes/theme-eco-marathon/theme-eco-marathon.css +22 -0
- package/src/content/themes/theme-energy-transition-campus-amsterdam/theme-energy-transition-campus-amsterdam.css +26 -0
- package/src/content/themes/theme-evpass/theme-evpass.css +46 -0
- package/src/content/themes/theme-nam-2025/resources/favicon/apple-touch-icon.png +0 -0
- package/src/content/themes/theme-nam-2025/resources/favicon/favico.ico +0 -0
- package/src/content/themes/theme-nam-2025/resources/favicon/favicon-96x96.png +0 -0
- package/src/content/themes/theme-nam-2025/resources/favicon/favicon.ico +0 -0
- package/src/content/themes/theme-nam-2025/resources/favicon/favicon.png +0 -0
- package/src/content/themes/theme-nam-2025/resources/favicon/favicon.svg +9 -0
- package/src/content/themes/theme-nam-2025/resources/favicon/google-touch-icon.png +0 -0
- package/src/content/themes/theme-nam-2025/resources/favicon/manifest.json +14 -0
- package/src/content/themes/theme-nam-2025/resources/favicon/site.webmanifest +21 -0
- package/src/content/themes/theme-nam-2025/resources/favicon/web-app-manifest-192x192.png +0 -0
- package/src/content/themes/theme-nam-2025/resources/favicon/web-app-manifest-512x512.png +0 -0
- package/src/content/themes/theme-nam-2025/theme-nam-2025.css +47 -0
- package/src/content/themes/theme-pennzoil/theme-pennzoil.css +36 -0
- package/src/content/themes/theme-quaker-state/theme-quaker-state.css +63 -0
- package/src/content/themes/theme-tafawoq/theme-tafawoq.css +26 -0
- package/src/content/themes/theme-vegetable/resources/favicon/apple-touch-icon.png +0 -0
- package/src/content/themes/theme-vegetable/resources/favicon/favico.ico +0 -0
- package/src/content/themes/theme-vegetable/resources/favicon/favicon-96x96.png +0 -0
- package/src/content/themes/theme-vegetable/resources/favicon/favicon.ico +0 -0
- package/src/content/themes/theme-vegetable/resources/favicon/favicon.png +0 -0
- package/src/content/themes/theme-vegetable/resources/favicon/favicon.svg +13 -0
- package/src/content/themes/theme-vegetable/resources/favicon/google-touch-icon.png +0 -0
- package/src/content/themes/theme-vegetable/resources/favicon/manifest.json +14 -0
- package/src/content/themes/theme-vegetable/resources/favicon/site.webmanifest +21 -0
- package/src/content/themes/theme-vegetable/resources/favicon/web-app-manifest-192x192.png +0 -0
- package/src/content/themes/theme-vegetable/resources/favicon/web-app-manifest-512x512.png +0 -0
- package/src/content/themes/theme-vegetable/theme-vegetable.css +49 -0
- package/src/content/themes/theme-zeolyst/resources/fonts/type-ar-medium.woff2 +0 -0
- package/src/content/themes/theme-zeolyst/theme-zeolyst.css +29 -0
- package/src/main/atoms/audio.js +16 -0
- package/src/main/atoms/box.js +5 -0
- package/src/main/atoms/button.js +40 -0
- package/src/main/atoms/card.js +22 -0
- package/src/main/atoms/form.js +30 -0
- package/src/main/atoms/heading.js +17 -0
- package/src/main/atoms/icon.js +24 -0
- package/src/main/atoms/img.js +131 -0
- package/src/main/atoms/input.js +55 -0
- package/src/main/atoms/link-text.js +21 -0
- package/src/main/atoms/link.js +60 -0
- package/src/main/atoms/list.js +12 -0
- package/src/main/atoms/logo.js +9 -0
- package/src/main/atoms/menu.js +10 -0
- package/src/main/atoms/message.js +5 -0
- package/src/main/atoms/nav-link.js +49 -0
- package/src/main/atoms/popup.js +47 -0
- package/src/main/atoms/rich-text.js +128 -0
- package/src/main/atoms/scroller.js +224 -0
- package/src/main/atoms/svg.js +65 -0
- package/src/main/atoms/table.js +32 -0
- package/src/main/atoms/textarea.js +10 -0
- package/src/main/atoms/time.js +12 -0
- package/src/main/atoms/video.js +100 -0
- package/src/main/export-main.js +12 -0
- package/src/main/export-matter.js +86 -0
- package/src/main/export-preact-hooks.js +1 -0
- package/src/main/export-preact.js +1 -0
- package/src/main/index.js +13 -0
- package/src/main/molecules/asset.js +23 -0
- package/src/main/molecules/glossary.js +44 -0
- package/src/main/molecules/links.js +23 -0
- package/src/main/molecules/promo-text.js +27 -0
- package/src/main/molecules/tags.js +15 -0
- package/src/main/molecules/tree.js +51 -0
- package/src/main/organisms/accordion-item.js +106 -0
- package/src/main/organisms/author.js +29 -0
- package/src/main/organisms/breadcrumb.js +69 -0
- package/src/main/organisms/call-to-action.js +24 -0
- package/src/main/organisms/carousel.js +178 -0
- package/src/main/organisms/cart-item.js +156 -0
- package/src/main/organisms/cart.js +162 -0
- package/src/main/organisms/contact-form.js +141 -0
- package/src/main/organisms/container/ab-test.js +47 -0
- package/src/main/organisms/container/default.js +6 -0
- package/src/main/organisms/container/filtered-section.js +293 -0
- package/src/main/organisms/container/footer.js +12 -0
- package/src/main/organisms/container/grid.js +44 -0
- package/src/main/organisms/container/header.js +13 -0
- package/src/main/organisms/container/list.js +7 -0
- package/src/main/organisms/container/main.js +6 -0
- package/src/main/organisms/container/raw.js +7 -0
- package/src/main/organisms/container/section.js +28 -0
- package/src/main/organisms/container.js +29 -0
- package/src/main/organisms/content-owner.js +15 -0
- package/src/main/organisms/date-entry.js +56 -0
- package/src/main/organisms/external-search.js +73 -0
- package/src/main/organisms/filtered-item.js +163 -0
- package/src/main/organisms/footer-item.js +17 -0
- package/src/main/organisms/image-gallery.js +164 -0
- package/src/main/organisms/last-modified.js +20 -0
- package/src/main/organisms/legal-footer.js +16 -0
- package/src/main/organisms/list-item.js +48 -0
- package/src/main/organisms/metadata.js +11 -0
- package/src/main/organisms/navigation.js +232 -0
- package/src/main/organisms/notification.js +87 -0
- package/src/main/organisms/order-tracker.js +203 -0
- package/src/main/organisms/page-header-banner.js +26 -0
- package/src/main/organisms/page-header.js +33 -0
- package/src/main/organisms/page-tags.js +14 -0
- package/src/main/organisms/page.js +260 -0
- package/src/main/organisms/press-release.js +24 -0
- package/src/main/organisms/product-admin.js +204 -0
- package/src/main/organisms/promo-banner.js +28 -0
- package/src/main/organisms/promo-bottom.js +23 -0
- package/src/main/organisms/promo-button.js +8 -0
- package/src/main/organisms/promo-card-cover.js +35 -0
- package/src/main/organisms/promo-card.js +33 -0
- package/src/main/organisms/promo-full.js +20 -0
- package/src/main/organisms/promo-image.js +22 -0
- package/src/main/organisms/promo-lure.js +22 -0
- package/src/main/organisms/promo-product-card.js +187 -0
- package/src/main/organisms/promo-product-full.js +293 -0
- package/src/main/organisms/promo-simple.js +23 -0
- package/src/main/organisms/quote.js +21 -0
- package/src/main/organisms/search-form.js +42 -0
- package/src/main/organisms/search-nav.js +66 -0
- package/src/main/organisms/search-result.js +53 -0
- package/src/main/organisms/slider.js +26 -0
- package/src/main/organisms/standalone-asset.js +22 -0
- package/src/main/organisms/tabs.js +277 -0
- package/src/main/organisms/topbar.js +83 -0
- package/src/main/organisms/web-component.js +53 -0
- package/src/main/routing/annotation.js +9 -0
- package/src/main/routing/component.js +138 -0
- package/src/main/routing/empty.js +5 -0
- package/src/main/routing/error-handler.js +64 -0
- package/src/main/routing/placeholder-image.svg +5 -0
- package/src/main/routing/router.js +219 -0
- package/src/main/shared/analytics.js +677 -0
- package/src/main/shared/bubble-event.js +11 -0
- package/src/main/shared/custom-element.js +21 -0
- package/src/main/shared/deep-selector.js +28 -0
- package/src/main/shared/disable-transparency.js +10 -0
- package/src/main/shared/format-time.js +8 -0
- package/src/main/shared/get-id.js +5 -0
- package/src/main/shared/get-meta.js +3 -0
- package/src/main/shared/get-size-class.js +3 -0
- package/src/main/shared/get-size.js +11 -0
- package/src/main/shared/h.js +88 -0
- package/src/main/shared/hash-jump.js +33 -0
- package/src/main/shared/icons/arrow-back.svg +1 -0
- package/src/main/shared/icons/arrow-down.svg +1 -0
- package/src/main/shared/icons/arrow-next.svg +1 -0
- package/src/main/shared/icons/arrow-tail-right.svg +1 -0
- package/src/main/shared/icons/arrow-tail-up.svg +1 -0
- package/src/main/shared/icons/arrow-up.svg +1 -0
- package/src/main/shared/icons/asset-download.svg +1 -0
- package/src/main/shared/icons/logo.svg +5 -0
- package/src/main/shared/icons/low-carbon-placeholder.svg +9 -0
- package/src/main/shared/icons/media-pause.svg +1 -0
- package/src/main/shared/icons/media-play.svg +1 -0
- package/src/main/shared/icons/navigation-burger.svg +1 -0
- package/src/main/shared/icons/navigation-close.svg +1 -0
- package/src/main/shared/icons/navigation-link.svg +1 -0
- package/src/main/shared/icons/navigation-refresh.svg +1 -0
- package/src/main/shared/icons/navigation-search.svg +1 -0
- package/src/main/shared/icons/navigation-share.svg +1 -0
- package/src/main/shared/icons/toggle-newwindow.svg +1 -0
- package/src/main/shared/icons.js +18 -0
- package/src/main/shared/id-from-string.js +5 -0
- package/src/main/shared/mark-selection.js +19 -0
- package/src/main/shared/register.js +26 -0
- package/src/main/shared/renderer.js +43 -0
- package/src/main/shared/simple-consent-api.js +70 -0
- package/src/main/shared/split-links.js +11 -0
- package/src/main/shared/t.js +60 -0
- package/src/main/shared/twind.js +837 -0
- package/src/main/shared/update-head.js +34 -0
- package/src/main/shared/update-scrollbar-width.js +30 -0
- package/src/main/shared/use-link.js +151 -0
- package/src/main/shared/use-persistent-state.js +42 -0
- package/src/main/shared/wait-for-dom-ready.js +6 -0
- package/src/main/shared/wcm-mode.js +4 -0
- package/src/wcs/components/acinguiux-preact-doc/acinguiux-preact-doc.js +207 -0
- package/src/wcs/components/admin-dashboard/admin-dashboard.js +487 -0
- package/src/wcs/components/admin-login/admin-login.js +91 -0
- package/src/wcs/components/bazaar-voice/bazaar-voice.js +56 -0
- package/src/wcs/components/chatbot-koreai/chatbot-koreai.js +176 -0
- package/src/wcs/components/chatbot-koreai/koreai-transport.js +217 -0
- package/src/wcs/components/chatbot-ms/chatbot-ms.js +210 -0
- package/src/wcs/components/chatbot-test/chatbot-test.js +44 -0
- package/src/wcs/components/comparison-chart/comparison-chart.js +111 -0
- package/src/wcs/components/consent-banner/consent-banner.js +248 -0
- package/src/wcs/components/consent-banner/icons/ccpa.svg +6 -0
- package/src/wcs/components/consent-banner/icons/info.svg +1 -0
- package/src/wcs/components/consent-banner/provider-onetrust.js +131 -0
- package/src/wcs/components/decision-tree/arrow-back.svg +3 -0
- package/src/wcs/components/decision-tree/badges.js +37 -0
- package/src/wcs/components/decision-tree/decision-tree.js +162 -0
- package/src/wcs/components/dynamic-contact-details/dynamic-contact-details.js +111 -0
- package/src/wcs/components/example-accordion/example-accordion.js +10 -0
- package/src/wcs/components/example-asset/example-asset.js +12 -0
- package/src/wcs/components/example-form/example-form.js +59 -0
- package/src/wcs/components/example-nested/example-nested.js +10 -0
- package/src/wcs/components/example-routing/example-routing.js +51 -0
- package/src/wcs/components/example-rtl/example-rtl.js +28 -0
- package/src/wcs/components/example-tabs/example-tabs.js +12 -0
- package/src/wcs/components/example-web-component/example-web-component.js +34 -0
- package/src/wcs/components/floating-button/floating-button.js +17 -0
- package/src/wcs/components/formstack-form/fields/address.js +38 -0
- package/src/wcs/components/formstack-form/fields/checkbox.js +42 -0
- package/src/wcs/components/formstack-form/fields/date.js +22 -0
- package/src/wcs/components/formstack-form/fields/description.js +8 -0
- package/src/wcs/components/formstack-form/fields/input.js +8 -0
- package/src/wcs/components/formstack-form/fields/name.js +39 -0
- package/src/wcs/components/formstack-form/fields/radio.js +24 -0
- package/src/wcs/components/formstack-form/fields/rating.js +53 -0
- package/src/wcs/components/formstack-form/fields/section.js +8 -0
- package/src/wcs/components/formstack-form/fields/select.js +10 -0
- package/src/wcs/components/formstack-form/fields/textarea.js +8 -0
- package/src/wcs/components/formstack-form/fields/wrapper.js +11 -0
- package/src/wcs/components/formstack-form/formstack-form.js +280 -0
- package/src/wcs/components/fuel-prices/fuel-prices.js +45 -0
- package/src/wcs/components/furniture-overview/furniture-overview.js +115 -0
- package/src/wcs/components/gauge-value/gauge-value.js +65 -0
- package/src/wcs/components/help-centre/api.js +150 -0
- package/src/wcs/components/help-centre/help-centre.js +400 -0
- package/src/wcs/components/help-centre/icon-search.svg +1 -0
- package/src/wcs/components/image-gen/admin-panel.js +248 -0
- package/src/wcs/components/image-gen/image-gen.js +385 -0
- package/src/wcs/components/image-gen/labels.js +37 -0
- package/src/wcs/components/image-gen/use-api.js +392 -0
- package/src/wcs/components/inspired-gallery/inspired-gallery.js +118 -0
- package/src/wcs/components/launch-container/launch-container.js +95 -0
- package/src/wcs/components/launch-container/ledger.js +140 -0
- package/src/wcs/components/lng-map/lng-map.js +44 -0
- package/src/wcs/components/mouseflow-analytics/mouseflow-analytics.js +39 -0
- package/src/wcs/components/msds-search/msds-search.js +127 -0
- package/src/wcs/components/msds-search/navigation-search.svg +3 -0
- package/src/wcs/components/product-catalogue/icon-back.svg +3 -0
- package/src/wcs/components/product-catalogue/icon-cart.svg +3 -0
- package/src/wcs/components/product-catalogue/icon-close.svg +3 -0
- package/src/wcs/components/product-catalogue/product-catalogue.js +215 -0
- package/src/wcs/components/product-links/icon-cart.svg +3 -0
- package/src/wcs/components/product-links/product-links.js +43 -0
- package/src/wcs/components/rio-iframe/rio-iframe.js +137 -0
- package/src/wcs/components/salsify-products/filter-tools.js +60 -0
- package/src/wcs/components/salsify-products/icon-cart.svg +3 -0
- package/src/wcs/components/salsify-products/process-products.js +53 -0
- package/src/wcs/components/salsify-products/route-tools.js +54 -0
- package/src/wcs/components/salsify-products/salsify-products.js +281 -0
- package/src/wcs/components/shout-out/shout-out.js +51 -0
- package/src/wcs/components/simple-chart/simple-chart.js +53 -0
- package/src/wcs/components/single-stat/single-stat.js +85 -0
- package/src/wcs/components/site-feedback/site-feedback.js +56 -0
- package/src/wcs/components/skds-search/navigation-search.svg +3 -0
- package/src/wcs/components/skds-search/skds-search.js +103 -0
- package/src/wcs/components/smart-banner/smart-banner.js +104 -0
- package/src/wcs/components/standalone-table/arrow-up-down.svg +3 -0
- package/src/wcs/components/standalone-table/arrow-up.svg +3 -0
- package/src/wcs/components/standalone-table/standalone-table.js +440 -0
- package/src/wcs/components/station-locator/station-locator.js +49 -0
- package/src/wcs/components/store-badges/badges.js +60 -0
- package/src/wcs/components/store-badges/store-badges.js +93 -0
- package/src/wcs/components/topbar-button/person.svg +1 -0
- package/src/wcs/components/topbar-button/topbar-button.js +22 -0
- package/src/wcs/components/universal-gallery/universal-gallery.js +308 -0
- package/src/wcs/components/zendesk-chat/zendesk-chat.js +133 -0
- package/src/wcs/shared/chat-bot/README.md +61 -0
- package/src/wcs/shared/chat-bot/chat-bot.js +216 -0
- package/src/wcs/shared/chat-bot/resources/arrow-next.svg +1 -0
- package/src/wcs/shared/chat-bot/resources/navigation-close.svg +1 -0
- package/src/wcs/shared/chat-bot/resources/person.svg +1 -0
- package/src/wcs/shared/chat-bot/resources/upload.svg +1 -0
- package/src/wcs/shared/filtered-data/README.md +52 -0
- package/src/wcs/shared/filtered-data/fetch-data.js +33 -0
- package/src/wcs/shared/filtered-data/filtered-data.js +337 -0
- package/src/wcs/shared/promo-with-popup/icon-close.svg +3 -0
- package/src/wcs/shared/promo-with-popup/icon-next.svg +3 -0
- package/src/wcs/shared/promo-with-popup/icon-prev.svg +3 -0
- package/src/wcs/shared/promo-with-popup/promo-with-popup.js +93 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Box } from '../atoms/box.js'
|
|
2
|
+
import { Heading } from '../atoms/heading.js'
|
|
3
|
+
import { RichText } from '../atoms/rich-text.js'
|
|
4
|
+
import { Time } from '../atoms/time.js'
|
|
5
|
+
import { Tags } from '../molecules/tags.js'
|
|
6
|
+
import h from '../shared/h.js'
|
|
7
|
+
import { Links } from './links.js'
|
|
8
|
+
|
|
9
|
+
export function PromoText ({ _model, _level = 3, _size, _align, _variant, ...props }) {
|
|
10
|
+
const { title, text, date, links, tags } = _model
|
|
11
|
+
|
|
12
|
+
const hasLinks = links.length > 0
|
|
13
|
+
const hasText = text || title
|
|
14
|
+
|
|
15
|
+
return (hasText || hasLinks) && h(Box, {
|
|
16
|
+
...props,
|
|
17
|
+
className: 'break-words',
|
|
18
|
+
_style: id => `${id} table { overflow-wrap: normal; word-break: normal }`,
|
|
19
|
+
children: [
|
|
20
|
+
h(Tags, { _model: { tags } }),
|
|
21
|
+
title && h(Heading, { _level, _size, _align }, title),
|
|
22
|
+
date && h(Time, { _time: date }),
|
|
23
|
+
h(RichText, text),
|
|
24
|
+
h(Links, { _variant, _model: { links } })
|
|
25
|
+
]
|
|
26
|
+
})
|
|
27
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Link } from '../atoms/link.js'
|
|
2
|
+
import h from '../shared/h.js'
|
|
3
|
+
|
|
4
|
+
export function Tags ({ _model, ...props }) {
|
|
5
|
+
const { tags } = _model
|
|
6
|
+
if (tags.length === 0) {
|
|
7
|
+
return null
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return h('div', { ...props, role: 'list', className: 'flex flex-wrap gap-2' }, tags.map(link =>
|
|
11
|
+
h('div', { className: 'flex items-center', role: 'listitem' },
|
|
12
|
+
h(Link, { _variant: 'tag', _model: link })
|
|
13
|
+
)
|
|
14
|
+
))
|
|
15
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useMemo, useState } from 'preact/hooks'
|
|
2
|
+
import { NavLink } from '../atoms/nav-link.js'
|
|
3
|
+
import getId from '../shared/get-id.js'
|
|
4
|
+
import h from '../shared/h.js'
|
|
5
|
+
import t from '../shared/t.js'
|
|
6
|
+
|
|
7
|
+
export function Tree ({ _model, _level = 0, ...props }) {
|
|
8
|
+
return h('div', { ...props, className: _level === 0 ? 'py-1' : '', role: 'list' }, _model.links.map((link, index) =>
|
|
9
|
+
h('div', { role: 'listitem' },
|
|
10
|
+
// Make the first link bold.
|
|
11
|
+
h(Node, { _bold: (index === 0) ? true : undefined, _level, _model: link })
|
|
12
|
+
)
|
|
13
|
+
))
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function Node ({ _model, _level, _bold }) {
|
|
17
|
+
const { children, name, value } = _model
|
|
18
|
+
|
|
19
|
+
const ids = useMemo(() => ({ button: getId(), container: getId() }), [])
|
|
20
|
+
const [isVisible, setIsVisible] = useState(false)
|
|
21
|
+
|
|
22
|
+
const containerProps = { className: 'animate-expand' }
|
|
23
|
+
const linkProps = { _model, _level, _bold, _selection: 'right' }
|
|
24
|
+
const treeProps = {}
|
|
25
|
+
|
|
26
|
+
if (children) {
|
|
27
|
+
// Prepend children with 'go to' link.
|
|
28
|
+
const links = children.slice()
|
|
29
|
+
links.unshift({ name: t('Go to: {0}', name), value })
|
|
30
|
+
treeProps._model = { links }
|
|
31
|
+
treeProps._level = _level + 1
|
|
32
|
+
treeProps.id = ids.container
|
|
33
|
+
treeProps['aria-labelledby'] = ids.button
|
|
34
|
+
|
|
35
|
+
// Link is now parent.
|
|
36
|
+
linkProps._level = _level
|
|
37
|
+
linkProps._expanded = isVisible
|
|
38
|
+
linkProps.id = ids.button
|
|
39
|
+
linkProps.role = 'button'
|
|
40
|
+
linkProps['aria-expanded'] = `${isVisible}`
|
|
41
|
+
linkProps['aria-controls'] = ids.container
|
|
42
|
+
linkProps.onClick = event => setIsVisible(!isVisible) || event.preventDefault()
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return [
|
|
46
|
+
h(NavLink, linkProps),
|
|
47
|
+
children && isVisible && h('div', containerProps, [
|
|
48
|
+
h(Tree, treeProps)
|
|
49
|
+
])
|
|
50
|
+
]
|
|
51
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'preact/hooks'
|
|
2
|
+
import { Box } from '../atoms/box.js'
|
|
3
|
+
import { Heading } from '../atoms/heading.js'
|
|
4
|
+
import { Icon } from '../atoms/icon.js'
|
|
5
|
+
import { RichText } from '../atoms/rich-text.js'
|
|
6
|
+
import { Asset } from '../molecules/asset.js'
|
|
7
|
+
import { Links } from '../molecules/links.js'
|
|
8
|
+
import { ValidationError } from '../routing/error-handler.js'
|
|
9
|
+
import h from '../shared/h.js'
|
|
10
|
+
import { ARROW_DOWN } from '../shared/icons.js'
|
|
11
|
+
import idFromString from '../shared/id-from-string.js'
|
|
12
|
+
|
|
13
|
+
export function AccordionItem ({ _model, children, ...props }) {
|
|
14
|
+
const { title, links } = _model
|
|
15
|
+
|
|
16
|
+
if (!title) {
|
|
17
|
+
throw new ValidationError()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const ref = useRef(null)
|
|
21
|
+
const icon = links?.[0]?.icon
|
|
22
|
+
const microdata = getMicrodata(props._variant === 'faq')
|
|
23
|
+
const hashHandler = () => location.hash.substring(1) === idFromString(title) && ref.current?.setAttribute('open', '')
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
hashHandler()
|
|
27
|
+
globalThis.addEventListener('hashchange', hashHandler)
|
|
28
|
+
return () => globalThis.removeEventListener('hashchange', hashHandler)
|
|
29
|
+
}, [title])
|
|
30
|
+
|
|
31
|
+
return h('details', {
|
|
32
|
+
...props,
|
|
33
|
+
...microdata.question,
|
|
34
|
+
ref,
|
|
35
|
+
className: 'bg-bga text-txa w-full rounded-2xl relative border-txa/20 border',
|
|
36
|
+
_style: id => `
|
|
37
|
+
${id}::details-content { opacity: 0; transform: translateY(-8px); transition: all var(--anim-time) }
|
|
38
|
+
${id}[open]::details-content { opacity: 1; transform: translateY(0) }
|
|
39
|
+
${id}[open] summary div:last-child { transform: rotate(180deg) }
|
|
40
|
+
`,
|
|
41
|
+
children: [
|
|
42
|
+
h('summary', {
|
|
43
|
+
className: 'clickable w-full flex items-center gap-2 px-6 py-3 cursor-pointer rounded-2xl relative',
|
|
44
|
+
children: [
|
|
45
|
+
icon && h('div', { className: 'bg-bgb text-txb w-10 h-10 flex items-center justify-center rounded-full' },
|
|
46
|
+
h(Icon, icon)
|
|
47
|
+
),
|
|
48
|
+
h('div', { className: 'grow' },
|
|
49
|
+
h(Heading, { _level: '3', _size: '4', ...microdata.name }, title)
|
|
50
|
+
),
|
|
51
|
+
h('div', { className: 'shrink transition-all' },
|
|
52
|
+
h(Icon, { _size: 'sm' }, ARROW_DOWN)
|
|
53
|
+
)
|
|
54
|
+
]
|
|
55
|
+
}),
|
|
56
|
+
h('div', { ...microdata.answer },
|
|
57
|
+
h('div', { ...microdata.text },
|
|
58
|
+
h(Content, { _model, children })
|
|
59
|
+
)
|
|
60
|
+
)
|
|
61
|
+
]
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// PromoText cannot be reused due to legacy children support.
|
|
66
|
+
function Content ({ _model, children }) {
|
|
67
|
+
const { text, links, asset, image, video } = _model
|
|
68
|
+
const hasContent = text || asset.src || links.length > 0
|
|
69
|
+
if (hasContent) {
|
|
70
|
+
const filteredModel = { links: links.filter(l => l.name).map(l => ({ ...l, icon: null })) }
|
|
71
|
+
return h(Box,
|
|
72
|
+
asset.src && h('div', { className: 'rounded-lg overflow-hidden' },
|
|
73
|
+
h(Asset, { _model: { image, video } })
|
|
74
|
+
),
|
|
75
|
+
h(RichText, text),
|
|
76
|
+
links && h(Links, { _variant: 'full', _model: filteredModel })
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Legacy children support.
|
|
81
|
+
return children
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function getMicrodata (isFaq) {
|
|
85
|
+
const microdata = {}
|
|
86
|
+
|
|
87
|
+
if (isFaq) {
|
|
88
|
+
microdata.question = {
|
|
89
|
+
itemscope: '',
|
|
90
|
+
itemtype: 'https://schema.org/Question'
|
|
91
|
+
}
|
|
92
|
+
microdata.name = {
|
|
93
|
+
itemprop: 'name'
|
|
94
|
+
}
|
|
95
|
+
microdata.answer = {
|
|
96
|
+
itemscope: '',
|
|
97
|
+
itemtype: 'https://schema.org/Answer',
|
|
98
|
+
itemprop: 'acceptedAnswer'
|
|
99
|
+
}
|
|
100
|
+
microdata.text = {
|
|
101
|
+
itemprop: 'text'
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return microdata
|
|
106
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Img } from '../atoms/img.js'
|
|
2
|
+
import { Link } from '../atoms/link.js'
|
|
3
|
+
import { RichText } from '../atoms/rich-text.js'
|
|
4
|
+
import { ValidationError } from '../routing/error-handler.js'
|
|
5
|
+
import h from '../shared/h.js'
|
|
6
|
+
|
|
7
|
+
export function Author ({ _model, ...props }) {
|
|
8
|
+
const { image, links, text } = _model
|
|
9
|
+
if (links.length === 0) {
|
|
10
|
+
throw new ValidationError()
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return h('div', { ...props, className: 'bg-bga text-txa rounded-2xl flex flex-row p-6 gap-3' },
|
|
14
|
+
image.src && h('div', { className: 'shrink-0 w-12 h-12 rounded-full overflow-hidden' },
|
|
15
|
+
h(Img, { _model: image, _tall: true })
|
|
16
|
+
),
|
|
17
|
+
h('div', { className: 'grow space-y-2' },
|
|
18
|
+
h('div', { className: 'font-custom font-bold text-lg' },
|
|
19
|
+
...links.flatMap(link => [
|
|
20
|
+
link.value
|
|
21
|
+
? h(Link, { _model: link })
|
|
22
|
+
: link.name,
|
|
23
|
+
', '
|
|
24
|
+
]).slice(0, -1)
|
|
25
|
+
),
|
|
26
|
+
h(RichText, text)
|
|
27
|
+
)
|
|
28
|
+
)
|
|
29
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import h from '../shared/h.js'
|
|
2
|
+
import { Icon } from '../atoms/icon.js'
|
|
3
|
+
import { Link } from '../atoms/link.js'
|
|
4
|
+
import { ARROW_BACK, ARROW_NEXT } from '../shared/icons.js'
|
|
5
|
+
|
|
6
|
+
export function Breadcrumb ({ _model, ...props }) {
|
|
7
|
+
return h('div', {
|
|
8
|
+
...props,
|
|
9
|
+
className: 'text-sm w-full px-6 py-2 min-h-9 m-auto max-w-page',
|
|
10
|
+
children: _model.links.length > 1 && h(LinkTrail, { _model })
|
|
11
|
+
})
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function LinkTrail ({ _model }) {
|
|
15
|
+
const { links } = _model
|
|
16
|
+
|
|
17
|
+
// Get a list of <LI> elements.
|
|
18
|
+
const lis = []
|
|
19
|
+
for (let ii = 0; ii < links.length; ++ii) {
|
|
20
|
+
const { [ii]: link } = links
|
|
21
|
+
const isLast = ii === links.length - 1
|
|
22
|
+
const isSecondLast = ii === links.length - 2
|
|
23
|
+
|
|
24
|
+
const liProps = {
|
|
25
|
+
className: isSecondLast ? undefined : 'sm:hidden md:hidden',
|
|
26
|
+
itemscope: '',
|
|
27
|
+
itemtype: 'https://schema.org/ListItem',
|
|
28
|
+
itemprop: 'itemListElement'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const linkProps = {
|
|
32
|
+
'aria-current': isLast ? 'page' : null,
|
|
33
|
+
itemprop: 'item',
|
|
34
|
+
_variant: 'simple',
|
|
35
|
+
_model: link
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// <
|
|
39
|
+
isSecondLast && lis.push(
|
|
40
|
+
h('li', { className: 'lg:hidden', 'aria-hidden': true },
|
|
41
|
+
h(Icon, { _size: 'xs', _rtlFlip: true }, ARROW_BACK)
|
|
42
|
+
)
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
// Item
|
|
46
|
+
lis.push(h('li', liProps,
|
|
47
|
+
h(Link, linkProps,
|
|
48
|
+
h('span', { itemprop: 'name' }, link.name)
|
|
49
|
+
),
|
|
50
|
+
h('meta', { itemprop: 'position', content: ii + 1 })
|
|
51
|
+
))
|
|
52
|
+
|
|
53
|
+
// >
|
|
54
|
+
isLast || lis.push(
|
|
55
|
+
h('li', { className: 'sm:hidden md:hidden', 'aria-hidden': true },
|
|
56
|
+
h(Icon, { _size: 'xs', _rtlFlip: true }, ARROW_NEXT)
|
|
57
|
+
)
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return h('nav',
|
|
62
|
+
h('ol', {
|
|
63
|
+
className: 'flex items-center p-0 gap-2',
|
|
64
|
+
itemscope: '',
|
|
65
|
+
itemtype: 'https://schema.org/BreadcrumbList',
|
|
66
|
+
children: lis
|
|
67
|
+
})
|
|
68
|
+
)
|
|
69
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Button } from '../atoms/button.js'
|
|
2
|
+
import { ValidationError } from '../routing/error-handler.js'
|
|
3
|
+
import h from '../shared/h.js'
|
|
4
|
+
|
|
5
|
+
const MAX_LINKS = 3
|
|
6
|
+
const COL_COUNT = 6
|
|
7
|
+
const COL_SPAN = 2
|
|
8
|
+
|
|
9
|
+
export function CallToAction ({ _model, _variant, ...props }) {
|
|
10
|
+
const links = _model.links.slice(0, MAX_LINKS)
|
|
11
|
+
if (links.length === 0) {
|
|
12
|
+
throw new ValidationError()
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const isStacked = _variant === 'stacked'
|
|
16
|
+
const colstart = isStacked ? 'auto' : (COL_COUNT + 1) - COL_SPAN * links.length
|
|
17
|
+
const className = `p-6 bg-bga text-txa rounded-2xl flex flex-col gap-5 ${isStacked ? '' : 'lg:grid lg:grid-cols-12'}`
|
|
18
|
+
|
|
19
|
+
return h('div', { ...props, className }, links.map((link, ii) =>
|
|
20
|
+
h('div', { className: `w-full col-span-4 col-start-${ii === 0 ? colstart : 'auto'}` },
|
|
21
|
+
h(Button, { _model: link, _wide: true })
|
|
22
|
+
))
|
|
23
|
+
)
|
|
24
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { useEffect, useMemo, useRef, useState } from 'preact/hooks'
|
|
2
|
+
import h from '../shared/h.js'
|
|
3
|
+
|
|
4
|
+
export function Carousel ({
|
|
5
|
+
_model = {},
|
|
6
|
+
children,
|
|
7
|
+
autoplay: propAutoplay,
|
|
8
|
+
interval: propInterval,
|
|
9
|
+
dots: propDots,
|
|
10
|
+
ariaLabel: propAriaLabel,
|
|
11
|
+
...props
|
|
12
|
+
}) {
|
|
13
|
+
const autoplay = propAutoplay ?? _model.autoplay ?? false
|
|
14
|
+
const interval = Math.max(1000, Number(propInterval ?? _model.interval ?? 5000) || 5000)
|
|
15
|
+
const dots = propDots ?? _model.dots ?? true
|
|
16
|
+
const ariaLabel = propAriaLabel ?? _model.ariaLabel ?? 'Carousel'
|
|
17
|
+
|
|
18
|
+
const items = useMemo(() => {
|
|
19
|
+
if (Array.isArray(children)) {
|
|
20
|
+
return children.filter(Boolean)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return children ? [children] : []
|
|
24
|
+
}, [children])
|
|
25
|
+
|
|
26
|
+
const [index, setIndex] = useState(0)
|
|
27
|
+
const [isDragging, setIsDragging] = useState(false)
|
|
28
|
+
const timerRef = useRef(null)
|
|
29
|
+
const trackRef = useRef(null)
|
|
30
|
+
const dragStartX = useRef(0)
|
|
31
|
+
const dragOffsetX = useRef(0)
|
|
32
|
+
const dragActive = useRef(false)
|
|
33
|
+
const rafRef = useRef(null)
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (items.length === 0) {
|
|
37
|
+
return
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (index > items.length - 1) {
|
|
41
|
+
setIndex(0)
|
|
42
|
+
}
|
|
43
|
+
}, [index, items.length])
|
|
44
|
+
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (!autoplay || items.length < 2) {
|
|
47
|
+
return
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
timerRef.current = setInterval(() => {
|
|
51
|
+
setIndex(current => (current + 1) % items.length)
|
|
52
|
+
}, interval)
|
|
53
|
+
|
|
54
|
+
return () => {
|
|
55
|
+
clearInterval(timerRef.current)
|
|
56
|
+
}
|
|
57
|
+
}, [autoplay, interval, items.length])
|
|
58
|
+
|
|
59
|
+
if (items.length === 0) {
|
|
60
|
+
return null
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const snapToIndex = targetIndex => setIndex(Math.max(0, Math.min(targetIndex, items.length - 1)))
|
|
64
|
+
|
|
65
|
+
const handlePointerDown = event => {
|
|
66
|
+
if ((event.button && event.button !== 0) || event.target.closest('a, button')) {
|
|
67
|
+
return
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
dragActive.current = true
|
|
71
|
+
dragStartX.current = event.clientX
|
|
72
|
+
dragOffsetX.current = 0
|
|
73
|
+
setIsDragging(true)
|
|
74
|
+
event.currentTarget.setPointerCapture?.(event.pointerId)
|
|
75
|
+
if (trackRef.current) {
|
|
76
|
+
trackRef.current.style.transition = 'none'
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const handlePointerMove = event => {
|
|
81
|
+
if (!dragActive.current || !trackRef.current) {
|
|
82
|
+
return
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
dragOffsetX.current = event.clientX - dragStartX.current
|
|
86
|
+
|
|
87
|
+
if (rafRef.current) {
|
|
88
|
+
cancelAnimationFrame(rafRef.current)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
rafRef.current = requestAnimationFrame(() => {
|
|
92
|
+
if (trackRef.current) {
|
|
93
|
+
trackRef.current.style.transform = `translateX(calc(-${index * 100}% + ${dragOffsetX.current}px))`
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const handlePointerUp = event => {
|
|
99
|
+
if (!dragActive.current) {
|
|
100
|
+
return
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
dragActive.current = false
|
|
104
|
+
setIsDragging(false)
|
|
105
|
+
event.currentTarget.releasePointerCapture?.(event.pointerId)
|
|
106
|
+
|
|
107
|
+
const threshold = 60
|
|
108
|
+
if (Math.abs(dragOffsetX.current) > threshold) {
|
|
109
|
+
if (dragOffsetX.current < 0) {
|
|
110
|
+
setIndex(current => (current + 1) % items.length)
|
|
111
|
+
} else {
|
|
112
|
+
setIndex(current => (current - 1 + items.length) % items.length)
|
|
113
|
+
}
|
|
114
|
+
} else {
|
|
115
|
+
snapToIndex(index)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
dragOffsetX.current = 0
|
|
119
|
+
if (trackRef.current) {
|
|
120
|
+
trackRef.current.style.transition = 'transform 600ms ease'
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (rafRef.current) {
|
|
124
|
+
cancelAnimationFrame(rafRef.current)
|
|
125
|
+
rafRef.current = null
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const progressPercent = items.length > 0 ? ((index + 1) / items.length) * 100 : 0
|
|
130
|
+
|
|
131
|
+
return h('div', {
|
|
132
|
+
...props,
|
|
133
|
+
role: 'region',
|
|
134
|
+
'aria-roledescription': 'carousel',
|
|
135
|
+
'aria-label': ariaLabel,
|
|
136
|
+
className: 'w-full relative',
|
|
137
|
+
children: [
|
|
138
|
+
h('div', {
|
|
139
|
+
className: 'relative overflow-hidden',
|
|
140
|
+
children: [
|
|
141
|
+
h('div', {
|
|
142
|
+
className: 'flex w-full cursor-grab active:cursor-grabbing select-none',
|
|
143
|
+
ref: trackRef,
|
|
144
|
+
style: {
|
|
145
|
+
transform: `translateX(-${index * 100}%)`,
|
|
146
|
+
transition: isDragging ? 'none' : 'transform 600ms ease',
|
|
147
|
+
touchAction: 'pan-y',
|
|
148
|
+
willChange: 'transform'
|
|
149
|
+
},
|
|
150
|
+
onPointerDown: handlePointerDown,
|
|
151
|
+
onPointerMove: handlePointerMove,
|
|
152
|
+
onPointerUp: handlePointerUp,
|
|
153
|
+
onPointerCancel: handlePointerUp,
|
|
154
|
+
onPointerLeave: handlePointerUp,
|
|
155
|
+
children: items.map((item, itemIndex) => h('div', {
|
|
156
|
+
className: 'min-w-full',
|
|
157
|
+
'aria-hidden': index !== itemIndex,
|
|
158
|
+
children: item
|
|
159
|
+
}))
|
|
160
|
+
}),
|
|
161
|
+
null
|
|
162
|
+
]
|
|
163
|
+
}),
|
|
164
|
+
dots && items.length > 1 && h('div', {
|
|
165
|
+
className: 'flex justify-center gap-2 sm:gap-3 mt-4',
|
|
166
|
+
children: items.map((_item, itemIndex) => h('button', {
|
|
167
|
+
type: 'button',
|
|
168
|
+
'aria-label': `Go to slide ${itemIndex + 1}`,
|
|
169
|
+
className: `h-5 w-5 sm:h-5 sm:w-5 flex items-center justify-center rounded-full ${index === itemIndex ? 'bg-bga' : 'bg-bgb/30 hover:bg-bgb'}`,
|
|
170
|
+
onClick: () => setIndex(itemIndex),
|
|
171
|
+
children: h('span', {
|
|
172
|
+
className: `block h-1 w-1 sm:h-3 sm:w-3 rounded-full ${index === itemIndex ? 'bg-txa' : 'bg-txa/50'}`
|
|
173
|
+
})
|
|
174
|
+
}))
|
|
175
|
+
})
|
|
176
|
+
]
|
|
177
|
+
})
|
|
178
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { useState, useEffect } from 'preact/hooks'
|
|
2
|
+
import { Img } from '../atoms/img.js'
|
|
3
|
+
import { Link } from '../atoms/link.js'
|
|
4
|
+
import { ValidationError } from '../routing/error-handler.js'
|
|
5
|
+
import h from '../shared/h.js'
|
|
6
|
+
|
|
7
|
+
export function CartItem ({ _model, ...props }) {
|
|
8
|
+
const {
|
|
9
|
+
title,
|
|
10
|
+
image,
|
|
11
|
+
price,
|
|
12
|
+
oldPrice,
|
|
13
|
+
currency = '\u20b9',
|
|
14
|
+
quantity: initialQty = 1,
|
|
15
|
+
maxQuantity,
|
|
16
|
+
unitLabel,
|
|
17
|
+
offerLabel,
|
|
18
|
+
savings,
|
|
19
|
+
links
|
|
20
|
+
} = _model
|
|
21
|
+
|
|
22
|
+
if (!title) {
|
|
23
|
+
throw new ValidationError()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const productLink = links?.[0]?.value
|
|
27
|
+
const [quantity, setQuantity] = useState(Math.max(1, Number.parseInt(initialQty, 10) || 1))
|
|
28
|
+
const maxQty = Number.parseInt(maxQuantity, 10)
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (initialQty != null) setQuantity(Math.max(1, Number.parseInt(initialQty, 10) || 1))
|
|
32
|
+
}, [initialQty])
|
|
33
|
+
|
|
34
|
+
const subtotal = (Number(price) || 0) * quantity
|
|
35
|
+
const computedSavings = savings ?? (oldPrice ? ((Number(oldPrice) - Number(price)) * quantity) : 0)
|
|
36
|
+
|
|
37
|
+
const onDecrease = () => setQuantity(current => Math.max(1, current - 1))
|
|
38
|
+
const onIncrease = () => {
|
|
39
|
+
setQuantity(current => {
|
|
40
|
+
if (Number.isFinite(maxQty) && current >= maxQty) return current
|
|
41
|
+
return current + 1
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return h('li', {
|
|
46
|
+
...props,
|
|
47
|
+
className: 'bg-bga text-txa border border-txa/10 rounded-lg sm:p-2 lg:p-4 w-full'
|
|
48
|
+
},
|
|
49
|
+
h('div', { className: 'grid grid-cols-12 gap-x-2 lg:gap-x-4 items-center' },
|
|
50
|
+
|
|
51
|
+
// Product image
|
|
52
|
+
h('div', { className: 'col-span-2 sm:col-span-3 lg:col-span-2' },
|
|
53
|
+
image?.src
|
|
54
|
+
? h(Img, {
|
|
55
|
+
_model: image,
|
|
56
|
+
_fit: 'contain',
|
|
57
|
+
className: 'w-full rounded-md bg-bgb/5',
|
|
58
|
+
style: 'aspect-ratio: 1 / 1;'
|
|
59
|
+
})
|
|
60
|
+
: h('div', { className: 'w-full rounded-md bg-txa/5', style: 'aspect-ratio: 1 / 1;' })
|
|
61
|
+
),
|
|
62
|
+
|
|
63
|
+
// Product info (name, price, offer, unit)
|
|
64
|
+
h('div', { className: 'col-span-5 sm:col-span-4 lg:col-span-5 flex flex-col justify-center sm:py-1 lg:py-3' },
|
|
65
|
+
h('div', { className: 'space-y-0.5 lg:space-y-1' },
|
|
66
|
+
productLink
|
|
67
|
+
? h(Link, {
|
|
68
|
+
_model: { value: productLink, name: title },
|
|
69
|
+
className: 'block font-semibold sm:text-xs lg:text-sm leading-tight'
|
|
70
|
+
}, title)
|
|
71
|
+
: h('span', { className: 'block font-semibold sm:text-xs lg:text-sm leading-tight' }, title),
|
|
72
|
+
|
|
73
|
+
h('div', { className: 'flex items-center gap-1 lg:gap-2' },
|
|
74
|
+
h('span', { className: 'sm:text-xs lg:text-sm font-bold' }, formatPrice(price, currency)),
|
|
75
|
+
oldPrice && h('span', { className: 'sm:text-[10px] lg:text-xs line-through opacity-60' }, formatPrice(oldPrice, currency))
|
|
76
|
+
),
|
|
77
|
+
|
|
78
|
+
unitLabel && h('span', { className: 'text-[10px] lg:text-xs text-txa/60' }, unitLabel),
|
|
79
|
+
|
|
80
|
+
offerLabel && h('div', { className: 'inline-flex items-center gap-1 mt-0.5' },
|
|
81
|
+
h('svg', { width: 12, height: 12, viewBox: '0 0 16 16', fill: 'none', className: 'shrink-0' },
|
|
82
|
+
h('path', {
|
|
83
|
+
'fill-rule': 'evenodd',
|
|
84
|
+
'clip-rule': 'evenodd',
|
|
85
|
+
d: 'M13.998 7.316H14c.367 0 .666.297.667.665a6.621 6.621 0 0 1-1.94 4.72 6.624 6.624 0 0 1-4.708 1.966H8a6.621 6.621 0 0 1-4.7-1.94A6.623 6.623 0 0 1 1.333 8.02a6.62 6.62 0 0 1 1.94-4.72A6.623 6.623 0 0 1 7.98 1.333c.53.008 1.07.062 1.587.186a.667.667 0 0 1-.313 1.296 5.878 5.878 0 0 0-1.27-.148 5.298 5.298 0 0 0-3.767 1.572 5.298 5.298 0 0 0-1.551 3.776 5.299 5.299 0 0 0 1.572 3.767A5.3 5.3 0 0 0 8 13.333h.015a5.297 5.297 0 0 0 3.767-1.572 5.3 5.3 0 0 0 1.551-3.776c0-.368.297-.668.665-.669Zm-8.47.213c.261-.261.683-.261.943 0l1.496 1.496 4.198-4.798a.667.667 0 0 1 1.003.879L8.5 10.439a.668.668 0 0 1-.48.228H8a.666.666 0 0 1-.471-.196l-2-2a.666.666 0 0 1 0-.942Z',
|
|
86
|
+
fill: 'currentColor'
|
|
87
|
+
})
|
|
88
|
+
),
|
|
89
|
+
h('span', { className: 'text-[10px] lg:text-xs font-semibold text-bgb' }, offerLabel)
|
|
90
|
+
)
|
|
91
|
+
)
|
|
92
|
+
),
|
|
93
|
+
|
|
94
|
+
// Quantity controls
|
|
95
|
+
h('div', { className: 'col-span-3 sm:col-span-3 lg:col-span-3 flex flex-col items-center justify-center gap-1 lg:gap-2' },
|
|
96
|
+
h('div', {
|
|
97
|
+
className: 'inline-flex items-center rounded-md border border-bgb overflow-hidden',
|
|
98
|
+
role: 'group',
|
|
99
|
+
'aria-label': 'Quantity selector'
|
|
100
|
+
},
|
|
101
|
+
h('button', {
|
|
102
|
+
type: 'button',
|
|
103
|
+
className: 'clickable bg-bgb text-txb sm:w-6 sm:h-6 lg:w-8 lg:h-8 text-sm lg:text-lg leading-none font-bold',
|
|
104
|
+
onClick: onDecrease,
|
|
105
|
+
'aria-label': 'Decrease quantity'
|
|
106
|
+
}, '\u2212'),
|
|
107
|
+
h('span', { className: 'px-2 lg:px-3 min-w-6 lg:min-w-8 text-center text-xs lg:text-sm font-semibold' }, quantity),
|
|
108
|
+
h('button', {
|
|
109
|
+
type: 'button',
|
|
110
|
+
className: 'clickable bg-bgb text-txb sm:w-6 sm:h-6 lg:w-8 lg:h-8 text-sm lg:text-lg leading-none font-bold',
|
|
111
|
+
onClick: onIncrease,
|
|
112
|
+
'aria-label': 'Increase quantity'
|
|
113
|
+
}, '+')
|
|
114
|
+
),
|
|
115
|
+
|
|
116
|
+
// Delete button
|
|
117
|
+
h('button', {
|
|
118
|
+
type: 'button',
|
|
119
|
+
className: 'clickable text-[10px] lg:text-xs text-txa/50 hover:text-txa transition',
|
|
120
|
+
'aria-label': 'Remove item'
|
|
121
|
+
},
|
|
122
|
+
h('span', { className: 'inline-flex items-center gap-0.5' },
|
|
123
|
+
h('svg', { width: 14, height: 14, viewBox: '0 0 24 24', fill: 'none', className: 'shrink-0' },
|
|
124
|
+
h('path', {
|
|
125
|
+
d: 'M19 7l-.867 12.142A2 2 0 0 1 16.138 21H7.862a2 2 0 0 1-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v3M4 7h16',
|
|
126
|
+
stroke: 'currentColor',
|
|
127
|
+
'stroke-width': '1.5',
|
|
128
|
+
'stroke-linecap': 'round',
|
|
129
|
+
'stroke-linejoin': 'round'
|
|
130
|
+
})
|
|
131
|
+
),
|
|
132
|
+
'Remove'
|
|
133
|
+
)
|
|
134
|
+
)
|
|
135
|
+
),
|
|
136
|
+
|
|
137
|
+
// Subtotal
|
|
138
|
+
h('div', { className: 'col-span-2 flex flex-col items-end justify-center' },
|
|
139
|
+
h('span', { className: 'sm:text-xs lg:text-sm font-bold' }, formatPrice(subtotal, currency)),
|
|
140
|
+
computedSavings > 0 && h('span', { className: 'text-[10px] lg:text-xs text-bgb font-semibold' }, `Saved: ${formatPrice(computedSavings, currency)}`)
|
|
141
|
+
)
|
|
142
|
+
)
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function formatPrice (value, currency) {
|
|
147
|
+
if (typeof value === 'number') {
|
|
148
|
+
return `${currency}${value % 1 === 0 ? value : value.toFixed(1)}`
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (typeof value === 'string' && value.length > 0) {
|
|
152
|
+
return value
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return `${currency}0`
|
|
156
|
+
}
|