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,64 @@
|
|
|
1
|
+
import { Component } from 'preact'
|
|
2
|
+
import h from '../shared/h.js'
|
|
3
|
+
import { isPublish } from '../shared/wcm-mode.js'
|
|
4
|
+
import { Annotation } from './annotation.js'
|
|
5
|
+
|
|
6
|
+
import { ARROW_TAIL_RIGHT } from '../shared/icons.js'
|
|
7
|
+
import PLACEHOLDER_IMAGE from './placeholder-image.svg'
|
|
8
|
+
|
|
9
|
+
const LINK_SRC = 'about:blank'
|
|
10
|
+
const PLACEHOLDER_CONTENT = {
|
|
11
|
+
title: 'Lorem ipsum dolor sit',
|
|
12
|
+
date: '2000-01-01T00:00:00.000Z',
|
|
13
|
+
text:
|
|
14
|
+
'Nunc lobortis mattis aliquam faucibus purus in massa tempor nec. ' +
|
|
15
|
+
'Morbi enim nunc faucibus a. ' +
|
|
16
|
+
'Nascetur ridiculus mus mauris vitae ultricies leo. ' +
|
|
17
|
+
'Aliquam ultrices sagittis orci a scelerisque purus semper. ' +
|
|
18
|
+
'Urna condimentum mattis pellentesque id nibh tortor id aliquet lectus.',
|
|
19
|
+
image: {
|
|
20
|
+
src: `data:image/svg+xml;utf-8,${encodeURIComponent(PLACEHOLDER_IMAGE)}`
|
|
21
|
+
},
|
|
22
|
+
links: [
|
|
23
|
+
{ name: 'Nunc lobortis', value: LINK_SRC, icon: ARROW_TAIL_RIGHT },
|
|
24
|
+
{ name: 'Volutpat ', value: LINK_SRC, icon: ARROW_TAIL_RIGHT },
|
|
25
|
+
{ name: 'Purus in massa', value: LINK_SRC, icon: ARROW_TAIL_RIGHT }
|
|
26
|
+
],
|
|
27
|
+
tags: [
|
|
28
|
+
{ name: 'Fermentum', value: '#' },
|
|
29
|
+
{ name: 'Turpis egestas', value: '#' },
|
|
30
|
+
{ name: 'Dignissim cras tincidunt ', value: '#' }
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class ValidationError extends Error {}
|
|
35
|
+
|
|
36
|
+
export class ErrorHandler extends Component {
|
|
37
|
+
state = { isValid: true }
|
|
38
|
+
|
|
39
|
+
componentDidCatch (error) {
|
|
40
|
+
if (error instanceof ValidationError) {
|
|
41
|
+
this.setState({ isValid: false })
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
render () {
|
|
46
|
+
if (this.state.isValid) {
|
|
47
|
+
return this.props.children
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (isPublish) {
|
|
51
|
+
return null
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const Organism = this.props.children.type
|
|
55
|
+
const organismProps = this.props.children.props
|
|
56
|
+
|
|
57
|
+
return h('div', { className: 'relative h-full' },
|
|
58
|
+
h(Annotation, 'Placeholder'),
|
|
59
|
+
h('div', { className: 'h-full opacity-50', 'data-placeholder': '' },
|
|
60
|
+
h(Organism, { ...organismProps, _model: PLACEHOLDER_CONTENT })
|
|
61
|
+
)
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/* global location */
|
|
2
|
+
import { useEffect, useState } from 'preact/hooks'
|
|
3
|
+
import getMeta from '../shared/get-meta.js'
|
|
4
|
+
import h from '../shared/h.js'
|
|
5
|
+
import { i18n } from '../shared/t.js'
|
|
6
|
+
import { Component } from './component.js'
|
|
7
|
+
|
|
8
|
+
const CLIENT_ERROR_CODE_LEVEL = 400
|
|
9
|
+
const FORWARDED_PARAMS = new Set(['q', 'tag', 'limit', 'offset', 'resource'])
|
|
10
|
+
|
|
11
|
+
// A very simplistic cache.
|
|
12
|
+
export const dataset = {}
|
|
13
|
+
|
|
14
|
+
async function doFetch (url, handleRedirections = false) {
|
|
15
|
+
if (dataset[url]) {
|
|
16
|
+
return dataset[url]
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let res
|
|
20
|
+
try {
|
|
21
|
+
res = await fetch(url)
|
|
22
|
+
} catch (error) {
|
|
23
|
+
// Network error
|
|
24
|
+
console.error(`Error when fetching: ${url}`)
|
|
25
|
+
console.error(error)
|
|
26
|
+
// Reload the page to follow e.g. potential external redirection blocked by CORS
|
|
27
|
+
globalThis.location.reload()
|
|
28
|
+
return {}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
if (res?.ok && res.status < CLIENT_ERROR_CODE_LEVEL) {
|
|
33
|
+
if (handleRedirections && res.redirected && res.headers.get('content-type')?.toLowerCase?.()?.startsWith?.('text/html')) {
|
|
34
|
+
// Redirect to an HTML page, use backend handling
|
|
35
|
+
globalThis.location.reload()
|
|
36
|
+
return {}
|
|
37
|
+
} else {
|
|
38
|
+
// Regular model fetch: add response to the cache and return
|
|
39
|
+
const obj = await res.json()
|
|
40
|
+
dataset[url] = obj
|
|
41
|
+
return obj
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
// Response status error
|
|
45
|
+
return null
|
|
46
|
+
}
|
|
47
|
+
} catch {
|
|
48
|
+
// Other response error (e.g. malformed JSON)
|
|
49
|
+
return null
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function fetchModelJson () {
|
|
54
|
+
// Fetch from .model.json.
|
|
55
|
+
let data = await doFetch(getModelHref(), true)
|
|
56
|
+
if (!data) {
|
|
57
|
+
// Fetch from error's page model.json if no data.
|
|
58
|
+
data = await doFetch(getModelHref(getMeta('error-url')))
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return data
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function getLocale (data) {
|
|
65
|
+
const links = (data ?? {})?.model?.links || []
|
|
66
|
+
return links.find?.(link => link?.name === 'locale')?.value
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function getLocaleRootHref (locale) {
|
|
70
|
+
if (!locale) {
|
|
71
|
+
return null
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return `/${locale.toLowerCase()}.html`
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
function fetchAcingUiUxI18nJson (pageData) {
|
|
79
|
+
// Fetch only if a cached copy does not exist or if the locale of the site does not match
|
|
80
|
+
// the locale of the dictionary (multilingual sites on the same domain).
|
|
81
|
+
const locale = getLocale(pageData)
|
|
82
|
+
const homeUrl = pageData?.model?.links?.find?.(link => link?.name === 'homeUrl')?.value
|
|
83
|
+
if (locale && (Object.keys(i18n).length === 0 || i18n.locale !== locale)) {
|
|
84
|
+
const localeRootHref = getLocaleRootHref(locale)
|
|
85
|
+
const preferredHref = localeRootHref || homeUrl
|
|
86
|
+
|
|
87
|
+
return doFetch(getI18nHref(preferredHref)).then(async data => {
|
|
88
|
+
// Fallback to home URL when locale-root dictionary does not exist.
|
|
89
|
+
if (!data && homeUrl && preferredHref !== homeUrl) {
|
|
90
|
+
data = await doFetch(getI18nHref(homeUrl))
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (data) {
|
|
94
|
+
Object.assign(i18n, data)
|
|
95
|
+
i18n.locale = locale
|
|
96
|
+
}
|
|
97
|
+
}).catch(() => null)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return null
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function resolvePartialModels (componentModel) {
|
|
104
|
+
if (!componentModel) {
|
|
105
|
+
return null
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (componentModel?.ref) {
|
|
109
|
+
return doFetch(componentModel.ref).then(partialData => {
|
|
110
|
+
if (partialData) {
|
|
111
|
+
Object.assign(componentModel, partialData)
|
|
112
|
+
delete componentModel.ref
|
|
113
|
+
const resolvedChildren = (componentModel?.children || []).map(child => resolvePartialModels(child))
|
|
114
|
+
return Promise.allSettled(resolvedChildren)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Skip resolving children if the partial model could not be fetched
|
|
118
|
+
return null
|
|
119
|
+
}).catch(() => null)
|
|
120
|
+
} else {
|
|
121
|
+
const resolvedChildren = (componentModel?.children || []).map(child => resolvePartialModels(child))
|
|
122
|
+
return Promise.allSettled(resolvedChildren)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function getModelHref (href = location) {
|
|
127
|
+
const url = new URL(href, location)
|
|
128
|
+
|
|
129
|
+
// Filter model params.
|
|
130
|
+
for (const param of url.searchParams.keys()) {
|
|
131
|
+
if (!FORWARDED_PARAMS.has(param)) {
|
|
132
|
+
url.searchParams.delete(param)
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Only use the "params" selector if there are search parameters to pass.
|
|
137
|
+
const base = url.pathname.replace(/\.html(\/.*)?$/, '')
|
|
138
|
+
url.pathname = url.searchParams.size > 0 ? `${base}.model.params.json` : `${base}.model.json`
|
|
139
|
+
|
|
140
|
+
// Model requests are resolved via fetch, so hash is useless as it is not passed to the server.
|
|
141
|
+
url.hash = ''
|
|
142
|
+
return url.href
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function getI18nHref (href = location) {
|
|
146
|
+
const url = new URL(href, location)
|
|
147
|
+
const base = url.origin + url.pathname.replace(/\.html(\/.*)?$/, '')
|
|
148
|
+
return `${base}.acinguiuxi18n.json`
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
async function route () {
|
|
152
|
+
// The i18n request needs to happen after model request for all the metadata
|
|
153
|
+
// to be available (= Page model's links).
|
|
154
|
+
const data = await fetchModelJson()
|
|
155
|
+
|
|
156
|
+
await Promise.allSettled([resolvePartialModels(data), fetchAcingUiUxI18nJson(data)])
|
|
157
|
+
return data
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Preact router component.
|
|
161
|
+
let lastUrl = new URL(location)
|
|
162
|
+
export function Router () {
|
|
163
|
+
// Ability to skip page rendering entirely.
|
|
164
|
+
if (new URLSearchParams(location.search).has('do-not-render')) {
|
|
165
|
+
return null
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const [data, setData] = useState(null)
|
|
169
|
+
|
|
170
|
+
useEffect(() => {
|
|
171
|
+
(async () => {
|
|
172
|
+
// Route for the first time.
|
|
173
|
+
const initialData = await route()
|
|
174
|
+
initialData && setData(initialData)
|
|
175
|
+
|
|
176
|
+
// Route for each popstate.
|
|
177
|
+
globalThis.addEventListener('popstate', async () => {
|
|
178
|
+
const newUrl = new URL(location)
|
|
179
|
+
|
|
180
|
+
// Do not route if suffix or hash change.
|
|
181
|
+
if (isHashOnly(lastUrl, newUrl) || isSuffixOnly(lastUrl, newUrl)) {
|
|
182
|
+
return
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const newData = await route()
|
|
186
|
+
newData && setData(newData)
|
|
187
|
+
|
|
188
|
+
// Reset scroll and focus only if the path is different.
|
|
189
|
+
if (newUrl.pathname !== lastUrl.pathname) {
|
|
190
|
+
document.activeElement.blur()
|
|
191
|
+
document.body.scrollTo(0, 0)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
lastUrl = newUrl
|
|
195
|
+
})
|
|
196
|
+
})()
|
|
197
|
+
}, [])
|
|
198
|
+
|
|
199
|
+
useEffect(() => {
|
|
200
|
+
globalThis.dispatchEvent(new CustomEvent('route'))
|
|
201
|
+
}, [lastUrl])
|
|
202
|
+
|
|
203
|
+
return data && h(Component, { _componentModel: data, _model: data.model })
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function isSuffixOnly (prevUrl, curUrl) {
|
|
207
|
+
// Suffixes are applied only after the html extension.
|
|
208
|
+
if (!curUrl.pathname.includes('.html')) {
|
|
209
|
+
return false
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const prevSuffix = prevUrl.pathname.split('.html').pop()
|
|
213
|
+
const curSuffix = curUrl.pathname.split('.html').pop()
|
|
214
|
+
return prevSuffix && prevUrl.href.replace(prevSuffix, '') === curUrl.href.replace(curSuffix, '')
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function isHashOnly (prevUrl, curUrl) {
|
|
218
|
+
return prevUrl.href.replace(prevUrl.hash, '') === curUrl.href.replace(curUrl.hash, '')
|
|
219
|
+
}
|