@coras-io/embed 0.10.0 → 0.12.0

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.
Files changed (46) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/components/attraction-card/base/attraction-card.mixin.js +17 -0
  3. package/dist/components/attraction-card/base/attraction-card.styles.js +2 -0
  4. package/dist/components/attraction-card/base/attraction-card.types.d.ts +2 -0
  5. package/dist/components/attraction-card/long/attraction-long-card.component.js +4 -2
  6. package/dist/components/attraction-card/short/attraction-short-card.component.d.ts +2 -0
  7. package/dist/components/attraction-card/short/attraction-short-card.component.js +16 -4
  8. package/dist/components/breadcrumbs/breadcrumb-item/breadcrumb-item.component.d.ts +6 -0
  9. package/dist/components/breadcrumbs/breadcrumb-item/breadcrumb-item.component.js +25 -5
  10. package/dist/components/breadcrumbs/breadcrumb-item/breadcrumb-item.styles.js +3 -1
  11. package/dist/components/image/image.component.d.ts +15 -0
  12. package/dist/components/image/image.component.js +55 -6
  13. package/dist/components/text-section/text-section.component.js +1 -1
  14. package/dist/components/text-section/text-section.styles.js +1 -1
  15. package/dist/containers/footer/footer.component.d.ts +2 -0
  16. package/dist/containers/footer/footer.component.js +29 -22
  17. package/dist/containers/navbar/navbar.component.d.ts +3 -0
  18. package/dist/containers/navbar/navbar.component.js +33 -10
  19. package/dist/contexts/events.context.d.ts +8 -0
  20. package/dist/contexts/events.context.js +6 -0
  21. package/dist/core/images/srcset.d.ts +16 -0
  22. package/dist/core/images/srcset.js +21 -0
  23. package/dist/core/images/url.d.ts +1 -0
  24. package/dist/core/images/url.js +3 -1
  25. package/dist/core/utils/link-click.d.ts +8 -0
  26. package/dist/core/utils/link-click.js +20 -0
  27. package/dist/index.d.ts +1 -1
  28. package/dist/mixins/base.mixin.d.ts +3 -0
  29. package/dist/mixins/base.mixin.js +29 -1
  30. package/dist/sdk/mount.js +1 -0
  31. package/dist/sdk/types.d.ts +12 -0
  32. package/dist/views/chrome-only-page/chrome-only-page.component.d.ts +2 -0
  33. package/dist/views/details-page/details-page.component.d.ts +4 -1
  34. package/dist/views/details-page/details-page.component.js +27 -43
  35. package/dist/views/details-page/details-page.styles.js +3 -0
  36. package/dist/views/details-page/partials/location-highlights/location-highlights.component.d.ts +2 -1
  37. package/dist/views/details-page/partials/location-highlights/location-highlights.component.js +12 -5
  38. package/dist/views/help-page/help-page.component.d.ts +2 -0
  39. package/dist/views/landing-page/landing-page.component.d.ts +4 -1
  40. package/dist/views/landing-page/landing-page.component.js +21 -16
  41. package/dist/views/payment-page/payment-page.component.d.ts +2 -0
  42. package/dist/views/search-page/search-page.component.d.ts +5 -2
  43. package/dist/views/search-page/search-page.component.js +41 -48
  44. package/dist/views/suggestion-widget/suggestion-widget.component.d.ts +5 -2
  45. package/dist/views/suggestion-widget/suggestion-widget.component.js +7 -4
  46. package/package.json +1 -1
@@ -32,7 +32,8 @@ import { renderSearchResultsOption } from "../../components/search-results-item/
32
32
  import { SearchMixin } from "../../mixins/search-mixin/search-mixin.js";
33
33
  import { addRecentlySelectedSearches, DrawerSubmenu, getLocaleLabel, getRecentlySelectedSearches, searchResultTypeToLocationPageMap, } from "./navbar.utils.js";
34
34
  import styles from "./navbar.styles.js";
35
- import { pageDispatchContext, } from "../../contexts/events.context.js";
35
+ import { pageDispatchContext, pageHrefContext, } from "../../contexts/events.context.js";
36
+ import { claimLinkClick } from "../../core/utils/link-click.js";
36
37
  import { assetsURLContext, currenciesContext, currencyContext, distributorIdContext, localeContext, localesContext, } from "../../contexts/properties.context.js";
37
38
  import { currentPageContext } from "../../contexts/current-page.context.js";
38
39
  import { clientContext } from "../../contexts/client.context.js";
@@ -96,11 +97,11 @@ let CorasNavBar = class CorasNavBar extends SearchMixin(LitElement) {
96
97
  // The logo is a home link. The embed owns no router, so it dispatches a
97
98
  // `landing` navigation the host applies (a no-op when already on landing).
98
99
  this.handleLogoClick = () => {
99
- this.dispatchPageUpdate({
100
- page: "landing",
101
- locale: this.locale,
102
- currency: this.currency,
103
- });
100
+ this.dispatchPageUpdate(this.homeTarget);
101
+ };
102
+ this.handleHomeLinkClick = (event) => {
103
+ if (claimLinkClick(event))
104
+ this.handleLogoClick();
104
105
  };
105
106
  }
106
107
  static { this.styles = styles; }
@@ -649,6 +650,13 @@ let CorasNavBar = class CorasNavBar extends SearchMixin(LitElement) {
649
650
  </coras-drawer>
650
651
  `;
651
652
  }
653
+ get homeTarget() {
654
+ return {
655
+ page: "landing",
656
+ locale: this.locale,
657
+ currency: this.currency,
658
+ };
659
+ }
652
660
  // The host's `brand` slot wins and keeps its own semantics: slotted content is
653
661
  // projected as-is, never wrapped, so a slotted link/button is not nested inside
654
662
  // our button (invalid interactive-in-interactive) and owns its own navigation.
@@ -666,8 +674,9 @@ let CorasNavBar = class CorasNavBar extends SearchMixin(LitElement) {
666
674
  }
667
675
  // A distributor with its own website links the logo straight there, the way its
668
676
  // main site does, and a real anchor keeps that a link (middle-click, new tab,
669
- // status bar). Without one there is no URL to link to, so the logo stays a
670
- // button dispatching the `landing` navigation for the host to route.
677
+ // status bar). Without one the logo links to the host's landing URL when the
678
+ // host gave the mount an `hrefFor`, routed in the app on a plain click, and
679
+ // otherwise stays a button dispatching the `landing` navigation.
671
680
  renderBrandHome(logo) {
672
681
  const image = html `<img
673
682
  class="brand-logo"
@@ -677,12 +686,23 @@ let CorasNavBar = class CorasNavBar extends SearchMixin(LitElement) {
677
686
  />`;
678
687
  // The URL comes from host config, so it is gated here rather than trusted.
679
688
  const href = safeUrl(this.logoHref);
680
- return href
689
+ if (href) {
690
+ return html `<a
691
+ class="brand-button"
692
+ part="brand-button"
693
+ href=${href}
694
+ aria-label=${msg("Go to the home page")}
695
+ >${image}</a
696
+ >`;
697
+ }
698
+ const homeHref = this._pageHref?.(this.homeTarget);
699
+ return homeHref
681
700
  ? html `<a
682
701
  class="brand-button"
683
702
  part="brand-button"
684
- href=${href}
703
+ href=${homeHref}
685
704
  aria-label=${msg("Go to the home page")}
705
+ @click=${this.handleHomeLinkClick}
686
706
  >${image}</a
687
707
  >`
688
708
  : html `<button
@@ -819,6 +839,9 @@ __decorate([
819
839
  __decorate([
820
840
  consume({ context: pageDispatchContext })
821
841
  ], CorasNavBar.prototype, "dispatchPageUpdate", void 0);
842
+ __decorate([
843
+ consume({ context: pageHrefContext })
844
+ ], CorasNavBar.prototype, "_pageHref", void 0);
822
845
  __decorate([
823
846
  consume({ context: basketContext, subscribe: true })
824
847
  ], CorasNavBar.prototype, "basket", void 0);
@@ -30,4 +30,12 @@ export type PageDispatchPayload = BasePageState & AllPageSpecificFields;
30
30
  export declare const pageDispatchContext: {
31
31
  __context__: (params: PageDispatchInput) => void;
32
32
  };
33
+ /**
34
+ * The host URL of the state a `dispatchPageUpdate` call would move to, for
35
+ * rendering that control as a link. `undefined` when the host gave the mount
36
+ * no `hrefFor`, so the control stays a button.
37
+ */
38
+ export declare const pageHrefContext: {
39
+ __context__: (params: PageDispatchInput) => string | undefined;
40
+ };
33
41
  export {};
@@ -1,2 +1,8 @@
1
1
  import { createContext } from "@lit/context";
2
2
  export const pageDispatchContext = createContext("coras-page-dispatch");
3
+ /**
4
+ * The host URL of the state a `dispatchPageUpdate` call would move to, for
5
+ * rendering that control as a link. `undefined` when the host gave the mount
6
+ * no `hrefFor`, so the control stays a button.
7
+ */
8
+ export const pageHrefContext = createContext("coras-page-href");
@@ -24,5 +24,21 @@ interface BuildSrcsetOptions extends Omit<ImgixOptions, "w" | "h" | "dpr"> {
24
24
  * straight to a `srcset` attribute without conditionals.
25
25
  */
26
26
  export declare function buildSrcset(src: string, widths?: readonly number[], options?: BuildSrcsetOptions): string;
27
+ export interface SourceSize {
28
+ width: number;
29
+ height: number;
30
+ }
31
+ /**
32
+ * The widest image imgix can cut from the source without enlarging it.
33
+ * `aspectRatio` is the ratio the image is cropped to: a crop narrower than
34
+ * the source runs out of height before it runs out of width.
35
+ */
36
+ export declare function maxWidthWithinSource(source: SourceSize, aspectRatio?: number): number;
37
+ /**
38
+ * Width candidates that never ask imgix to enlarge the source image. An
39
+ * enlarged image is a bigger download with no extra detail, so candidates
40
+ * wider than the source give way to one at the source's own size.
41
+ */
42
+ export declare function widthsWithinSource(widths: readonly number[], source: SourceSize, aspectRatio?: number): number[];
27
43
  export declare function buildSizes(preset: ImagePreset): string;
28
44
  export {};
@@ -29,6 +29,27 @@ export function buildSrcset(src, widths = RESPONSIVE_WIDTHS, options = {}) {
29
29
  })
30
30
  .join(", ");
31
31
  }
32
+ /**
33
+ * The widest image imgix can cut from the source without enlarging it.
34
+ * `aspectRatio` is the ratio the image is cropped to: a crop narrower than
35
+ * the source runs out of height before it runs out of width.
36
+ */
37
+ export function maxWidthWithinSource(source, aspectRatio) {
38
+ return Math.floor(aspectRatio
39
+ ? Math.min(source.width, source.height * aspectRatio)
40
+ : source.width);
41
+ }
42
+ /**
43
+ * Width candidates that never ask imgix to enlarge the source image. An
44
+ * enlarged image is a bigger download with no extra detail, so candidates
45
+ * wider than the source give way to one at the source's own size.
46
+ */
47
+ export function widthsWithinSource(widths, source, aspectRatio) {
48
+ const max = maxWidthWithinSource(source, aspectRatio);
49
+ if (widths.every((w) => w <= max))
50
+ return Array.from(widths);
51
+ return [...widths.filter((w) => w < max), max];
52
+ }
32
53
  /**
33
54
  * Slot presets for the `sizes` attribute. These describe the rendered size of
34
55
  * the image in the layout, NOT the viewport - which is exactly what `sizes`
@@ -20,4 +20,5 @@ export interface ImgixOptions {
20
20
  fpX?: number;
21
21
  fpY?: number;
22
22
  }
23
+ export declare const DEFAULT_QUALITY = 45;
23
24
  export declare function buildImgixUrl(src: string, opts?: ImgixOptions): string;
@@ -8,7 +8,9 @@
8
8
  * not call this helper.
9
9
  */
10
10
  const DEFAULT_AUTO = "compress,format";
11
- const DEFAULT_QUALITY = 85;
11
+ // The quality imgix itself uses for `auto=compress`. Photos at 85 were about
12
+ // a third larger with no visible gain at the sizes the SDK shows them.
13
+ export const DEFAULT_QUALITY = 45;
12
14
  export function buildImgixUrl(src, opts = {}) {
13
15
  if (!src)
14
16
  return "";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Claims a click on a link the host routes. A plain left click is claimed: its
3
+ * default is prevented so the page does not load the href, and `true` tells the
4
+ * caller (or a listener up the tree) to emit the navigation intent instead. A
5
+ * modified click is left to the browser, which opens the href in a new tab or
6
+ * window, and is stopped from reaching the listeners that would also navigate.
7
+ */
8
+ export declare function claimLinkClick(event: MouseEvent): boolean;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Claims a click on a link the host routes. A plain left click is claimed: its
3
+ * default is prevented so the page does not load the href, and `true` tells the
4
+ * caller (or a listener up the tree) to emit the navigation intent instead. A
5
+ * modified click is left to the browser, which opens the href in a new tab or
6
+ * window, and is stopped from reaching the listeners that would also navigate.
7
+ */
8
+ export function claimLinkClick(event) {
9
+ const modified = event.button !== 0 ||
10
+ event.metaKey ||
11
+ event.ctrlKey ||
12
+ event.shiftKey ||
13
+ event.altKey;
14
+ if (modified) {
15
+ event.stopPropagation();
16
+ return false;
17
+ }
18
+ event.preventDefault();
19
+ return true;
20
+ }
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { mount } from "./sdk/mount.js";
2
2
  export { CorasValidationError, type CorasValidationErrorCode, } from "./sdk/validation.js";
3
- export type { CorasApp, CorasConfig, CorasLoyaltyProgramme, CorasTheme, CorasColorScheme, CorasChrome, CorasChromeOptions, CorasNavbar, CorasFooter, CorasManagedNavbar, CorasManagedFooter, CorasNavbarSlotName, CorasNavbarProps, CorasMountOptions, CorasState, CorasUpdate, CorasConfigUpdate, CorasNavigateOptions, CorasCallbacks, CorasLogger, CorasObservabilityEvent, CorasPageName, CorasPageParams, CorasPageParamsByPage, CorasLandingPageParams, CorasSearchPageParams, CorasDetailsPageParams, CorasPaymentPageParams, CorasHelpPageParams, CorasSuggestionWidgetParams, CorasHostEventMap, CorasHostEventName, CorasReadyDetail, CorasNavigateDetail, CorasStateChangeDetail, CorasReservationCreatedDetail, CorasPaymentStatusDetail, CorasPaymentStatus, CorasErrorDetail, CorasNavigationSource, } from "./sdk/types.js";
3
+ export type { CorasApp, CorasConfig, CorasLoyaltyProgramme, CorasTheme, CorasColorScheme, CorasChrome, CorasChromeOptions, CorasNavbar, CorasFooter, CorasManagedNavbar, CorasManagedFooter, CorasNavbarSlotName, CorasNavbarProps, CorasMountOptions, CorasState, CorasUpdate, CorasConfigUpdate, CorasNavigateOptions, CorasCallbacks, CorasLogger, CorasHrefFor, CorasObservabilityEvent, CorasPageName, CorasPageParams, CorasPageParamsByPage, CorasLandingPageParams, CorasSearchPageParams, CorasDetailsPageParams, CorasPaymentPageParams, CorasHelpPageParams, CorasSuggestionWidgetParams, CorasHostEventMap, CorasHostEventName, CorasReadyDetail, CorasNavigateDetail, CorasStateChangeDetail, CorasReservationCreatedDetail, CorasPaymentStatusDetail, CorasPaymentStatus, CorasErrorDetail, CorasNavigationSource, } from "./sdk/types.js";
4
4
  export type { SupportedLocales } from "./core/types/core/locale.js";
5
5
  export type { SupportedCurrencies } from "./core/types/core/currency.js";
6
6
  export { allLocales } from "./core/i18n/locale-codes.js";
@@ -5,6 +5,7 @@ import type { Client } from "openapi-fetch";
5
5
  import type { LoyaltyProgramme } from "../core/utils/loyalty.js";
6
6
  import type { Constructor } from "../contexts/utils.js";
7
7
  import { type PageDispatchInput } from "../contexts/events.context.js";
8
+ import type { CorasHrefFor } from "../sdk/types.js";
8
9
  import { type Logger } from "../core/logger.js";
9
10
  import type { PageParamsEvent } from "../core/pages.js";
10
11
  type BaseMixinProperties<CustomPageContext extends PageParamsEvent> = {
@@ -18,9 +19,11 @@ type BaseMixinProperties<CustomPageContext extends PageParamsEvent> = {
18
19
  loyaltyPoints: boolean;
19
20
  loyaltyProgramme: LoyaltyProgramme | null;
20
21
  logger: Logger;
22
+ hrefFor: CorasHrefFor | null;
21
23
  client: Client<paths>;
22
24
  getPageProperties(): CustomPageContext;
23
25
  dispatchPageUpdate(params: PageDispatchInput): void;
26
+ pageUpdateHref(params: PageDispatchInput): string | undefined;
24
27
  };
25
28
  export declare const BaseMixin: <T extends Constructor<LitElement>, CustomPageContext extends PageParamsEvent>(superClass: T) => Constructor<BaseMixinProperties<CustomPageContext>> & T;
26
29
  export {};
@@ -13,7 +13,7 @@ import { allLocales } from "../core/i18n/locale-codes.js";
13
13
  import { getTextDirection } from "../core/utils/locale.js";
14
14
  import { ContextRoot, provide } from "@lit/context";
15
15
  import { clientContext } from "../contexts/client.context.js";
16
- import { pageDispatchContext, } from "../contexts/events.context.js";
16
+ import { pageDispatchContext, pageHrefContext, } from "../contexts/events.context.js";
17
17
  import { fireEvent } from "../core/events.js";
18
18
  import { classifyPageUpdate } from "../sdk/navigation-intent.js";
19
19
  import { apiHostContext, assetsURLContext, loyaltyPointsContext, loyaltyProgrammeContext, currenciesContext, currencyContext, distributorIdContext, localeContext, localesContext, } from "../contexts/properties.context.js";
@@ -38,7 +38,10 @@ export const BaseMixin = (superClass) => {
38
38
  // Set by the SDK mount, not an attribute: a host cannot pass a function
39
39
  // through markup, so the default stays silent until `mount` wires one.
40
40
  this.logger = NOOP_LOGGER;
41
+ // The host's `hrefFor` mount option, set by the SDK mount like the logger.
42
+ this.hrefFor = null;
41
43
  this._pageDispatch = this.dispatchPageUpdate.bind(this);
44
+ this._pageHref = this.pageUpdateHref.bind(this);
42
45
  // Replays context requests that arrive before their provider renders
43
46
  // inside this page's shadow DOM. See docs/ARCHITECTURE.md.
44
47
  new ContextRoot().attach(this);
@@ -46,6 +49,25 @@ export const BaseMixin = (superClass) => {
46
49
  getPageProperties() {
47
50
  return {};
48
51
  }
52
+ // The link for a control that would call `dispatchPageUpdate` with the same
53
+ // params. Unlike a same-page dispatch, which merges the current params in,
54
+ // the link names the target state alone: a crumb or the logo opened in a
55
+ // new tab lands on that page as a visitor would reach it, not with this
56
+ // page's filters carried over.
57
+ pageUpdateHref(params) {
58
+ if (!this.hrefFor)
59
+ return undefined;
60
+ const { page, currency, locale, href, text, ...pageSpecific } = params;
61
+ void text;
62
+ return this.hrefFor({
63
+ page: page ?? this.currentPage,
64
+ params: pageSpecific,
65
+ locale: locale ?? this.locale,
66
+ currency: currency ?? this.currency,
67
+ ...(href != null ? { href } : {}),
68
+ source: "embed",
69
+ });
70
+ }
49
71
  dispatchPageUpdate(params) {
50
72
  const { page, currency, locale, href, text, ...pageSpecific } = params;
51
73
  // External-link text is not part of the minimal public payload.
@@ -134,8 +156,14 @@ export const BaseMixin = (superClass) => {
134
156
  __decorate([
135
157
  provide({ context: loggerContext })
136
158
  ], BaseMixinElement.prototype, "logger", void 0);
159
+ __decorate([
160
+ property({ attribute: false })
161
+ ], BaseMixinElement.prototype, "hrefFor", void 0);
137
162
  __decorate([
138
163
  provide({ context: pageDispatchContext })
139
164
  ], BaseMixinElement.prototype, "_pageDispatch", void 0);
165
+ __decorate([
166
+ provide({ context: pageHrefContext })
167
+ ], BaseMixinElement.prototype, "_pageHref", void 0);
140
168
  return BaseMixinElement;
141
169
  };
package/dist/sdk/mount.js CHANGED
@@ -178,6 +178,7 @@ export function createMountWith(registry) {
178
178
  // set directly on the element; pages that honor it read their own property.
179
179
  element.preview = preview;
180
180
  element.logger = toLogger(options.logger);
181
+ element.hrefFor = options.hrefFor ?? null;
181
182
  const paramDefaults = captureParamDefaults(element, entry);
182
183
  applyParams(element, entry, currentParams, paramDefaults);
183
184
  // Chrome is rebuilt per page rather than moved: the navbar/footer consume
@@ -242,6 +242,7 @@ export type CorasCallbacks = {
242
242
  onError?: (detail: CorasErrorDetail) => void;
243
243
  onObservability?: (event: CorasObservabilityEvent) => void;
244
244
  };
245
+ export type CorasHrefFor = (intent: CorasNavigateDetail) => string | undefined;
245
246
  /**
246
247
  * `mount()` is generic over `P`, so a call passing a literal page gets its own
247
248
  * params checked against it. The alias is deliberately *not* distributed over
@@ -266,6 +267,17 @@ export type CorasMountOptions<P extends CorasPageName = CorasPageName> = {
266
267
  */
267
268
  content?: HTMLElement;
268
269
  logger?: CorasLogger;
270
+ /**
271
+ * The URL the host would route a navigation intent to. When set, pages render
272
+ * their internal navigation (attraction cards, breadcrumbs, the navbar logo,
273
+ * the footer's help links) as real `<a href>` links that crawlers follow,
274
+ * built the same way `onNavigate` routes them (usually with `buildCorasUrl`).
275
+ * A plain click on such a link still emits `onNavigate` and never loads the
276
+ * page; a modified or middle click opens the href the browser's way. Return
277
+ * `undefined` for an intent that has no link. Unset, those controls stay
278
+ * buttons.
279
+ */
280
+ hrefFor?: CorasHrefFor;
269
281
  /** Reject unknown config/param keys instead of ignoring them. */
270
282
  strict?: boolean;
271
283
  /**
@@ -12,9 +12,11 @@ declare const CorasChromeOnlyPage_base: import("../../contexts/utils.js").Constr
12
12
  loyaltyPoints: boolean;
13
13
  loyaltyProgramme: import("../../index.js").CorasLoyaltyProgramme | null;
14
14
  logger: import("../../core/logger.js").Logger;
15
+ hrefFor: import("../../index.js").CorasHrefFor | null;
15
16
  client: import("openapi-fetch").Client<import("../../core/types/api-schema.js").paths>;
16
17
  getPageProperties(): PageParamsEvent;
17
18
  dispatchPageUpdate(params: import("../../contexts/events.context.js").PageDispatchInput): void;
19
+ pageUpdateHref(params: import("../../contexts/events.context.js").PageDispatchInput): string | undefined;
18
20
  }> & typeof LitElement;
19
21
  /**
20
22
  * The managed chrome around markup the host owns, with no Coras page inside it.
@@ -1,5 +1,6 @@
1
1
  import { type CSSResultGroup, LitElement, type PropertyValues } from "lit";
2
2
  import { Task } from "@lit/task";
3
+ import type { PageDispatchInput } from "../../contexts/events.context.js";
3
4
  import type { SupportedLocales, SupportedCurrencies } from "../../core/types/index.js";
4
5
  import "../../components/button/button.js";
5
6
  import "../../components/attraction-header/attraction-header.js";
@@ -48,9 +49,11 @@ declare const CorasDetailsPage_base: import("../../contexts/utils.js").Construct
48
49
  loyaltyPoints: boolean;
49
50
  loyaltyProgramme: import("../../core/utils/loyalty.js").LoyaltyProgramme | null;
50
51
  logger: import("../../core/logger.js").Logger;
52
+ hrefFor: import("../../index.js").CorasHrefFor | null;
51
53
  client: import("openapi-fetch").Client<import("../../core/types/api-schema.js").paths>;
52
54
  getPageProperties(): DetailsPageParamsEvent;
53
- dispatchPageUpdate(params: import("../../contexts/events.context.js").PageDispatchInput): void;
55
+ dispatchPageUpdate(params: PageDispatchInput): void;
56
+ pageUpdateHref(params: PageDispatchInput): string | undefined;
54
57
  }> & typeof LitElement;
55
58
  /**
56
59
  * @fires coras:navigate
@@ -11,6 +11,7 @@ import { state, property } from "lit/decorators.js";
11
11
  import { Task, TaskStatus } from "@lit/task";
12
12
  import { localized, msg, str } from "@lit/localize";
13
13
  import { classMap } from "lit/directives/class-map.js";
14
+ import { ifDefined } from "lit/directives/if-defined.js";
14
15
  import { fireEvent } from "../../core/events.js";
15
16
  import { map } from "lit/directives/map.js";
16
17
  import { consume } from "@lit/context";
@@ -431,14 +432,19 @@ let CorasDetailsPage = class CorasDetailsPage extends ErrorModalMixin(BaseMixin(
431
432
  if (!images) {
432
433
  return html ``;
433
434
  }
434
- return html `${map(images, (image) => html `
435
+ // The first image is the page's largest content, so it loads at once and
436
+ // ahead of the other images. The rest wait until the carousel shows them.
437
+ return html `${map(images, (image, index) => html `
435
438
  <coras-better-carousel-item>
436
439
  <coras-image
437
440
  src=${image.url}
438
441
  width=${IMAGE_CAROUSEL_WIDTH}
439
442
  height=${IMAGE_CAROUSEL_HEIGHT}
443
+ source-width=${image.width ?? nothing}
444
+ source-height=${image.height ?? nothing}
440
445
  preset="carousel-hero"
441
- loading="lazy"
446
+ loading=${index === 0 ? "eager" : "lazy"}
447
+ fetch-priority=${index === 0 ? "high" : "auto"}
442
448
  alt=""
443
449
  ></coras-image>
444
450
  </coras-better-carousel-item>
@@ -1380,50 +1386,28 @@ let CorasDetailsPage = class CorasDetailsPage extends ErrorModalMixin(BaseMixin(
1380
1386
  if (!summary)
1381
1387
  return nothing;
1382
1388
  const { cityName, citySlug, countryName, countrySlug } = summary;
1383
- const handleCountryClick = () => {
1384
- if (!countrySlug)
1385
- return;
1386
- this.dispatchPageUpdate({
1387
- page: "landing",
1388
- country: countrySlug,
1389
- city: "",
1390
- });
1391
- };
1392
- const handleCityClick = () => {
1393
- if (!countrySlug || !citySlug)
1394
- return;
1395
- this.dispatchPageUpdate({
1396
- page: "landing",
1397
- country: countrySlug,
1398
- city: citySlug,
1399
- });
1400
- };
1401
- const handleCategoryClick = () => {
1402
- if (!countrySlug || !citySlug)
1403
- return;
1404
- this.dispatchPageUpdate({
1405
- page: "landing",
1406
- country: countrySlug,
1407
- city: citySlug,
1408
- categories: attraction.main_category.slug,
1409
- });
1410
- };
1389
+ const countryTarget = countrySlug
1390
+ ? { page: "landing", country: countrySlug, city: "" }
1391
+ : null;
1392
+ const cityTarget = countrySlug && citySlug
1393
+ ? { page: "landing", country: countrySlug, city: citySlug }
1394
+ : null;
1395
+ const categoryTarget = cityTarget
1396
+ ? { ...cityTarget, categories: attraction.main_category.slug }
1397
+ : null;
1398
+ const renderLink = (label, target) => html `<coras-breadcrumb-item
1399
+ href=${ifDefined(target ? this.pageUpdateHref(target) : undefined)}
1400
+ @click=${() => target && this.dispatchPageUpdate(target)}
1401
+ clickable
1402
+ >
1403
+ ${label}
1404
+ </coras-breadcrumb-item>`;
1411
1405
  return html `
1412
1406
  <coras-breadcrumbs assets-url="${this.assetsURL}">
1413
- ${countryName
1414
- ? html `<coras-breadcrumb-item @click=${handleCountryClick} clickable>
1415
- ${countryName}
1416
- </coras-breadcrumb-item>`
1417
- : nothing}
1418
- ${cityName
1419
- ? html `<coras-breadcrumb-item @click=${handleCityClick} clickable>
1420
- ${cityName}
1421
- </coras-breadcrumb-item>`
1422
- : nothing}
1407
+ ${countryName ? renderLink(countryName, countryTarget) : nothing}
1408
+ ${cityName ? renderLink(cityName, cityTarget) : nothing}
1423
1409
  ${attraction.main_category.name
1424
- ? html `<coras-breadcrumb-item @click=${handleCategoryClick} clickable>
1425
- ${attraction.main_category.name}
1426
- </coras-breadcrumb-item>`
1410
+ ? renderLink(attraction.main_category.name, categoryTarget)
1427
1411
  : nothing}
1428
1412
  <coras-breadcrumb-item>
1429
1413
  ${attraction.attraction_name}
@@ -10,6 +10,9 @@ export default css `
10
10
  display: flex;
11
11
  flex-direction: column;
12
12
  gap: 1.75rem;
13
+ /* The loaded page is taller than the screen. Without this the footer
14
+ shows under the short skeleton and jumps away when the content comes. */
15
+ min-height: 100dvh;
13
16
 
14
17
  .sk-breadcrumb {
15
18
  width: 14rem;
@@ -21,8 +21,9 @@ export declare class CorasLocationHighlights extends LitElement {
21
21
  currency: SupportedCurrencies;
22
22
  loyaltyProgramme: LoyaltyProgramme | null;
23
23
  dispatchPageUpdate: (params: PageDispatchInput) => void;
24
+ private _pageHref?;
24
25
  private highlightsTask;
25
- private handleCardClick;
26
+ private cardTarget;
26
27
  private renderCard;
27
28
  render(): typeof nothing | import("lit").TemplateResult<1> | undefined;
28
29
  }
@@ -6,6 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  import { LitElement, html, nothing } from "lit";
8
8
  import { property } from "lit/decorators.js";
9
+ import { ifDefined } from "lit/directives/if-defined.js";
9
10
  import { consume } from "@lit/context";
10
11
  import { localized, msg, str } from "@lit/localize";
11
12
  import { Task } from "@lit/task";
@@ -16,7 +17,7 @@ import { APIError } from "../../../../core/api/api-error.js";
16
17
  import { convertToLocaleCurrency } from "../../../../core/currency/index.js";
17
18
  import { clientContext } from "../../../../contexts/client.context.js";
18
19
  import { currencyContext, distributorIdContext, localeContext, loyaltyProgrammeContext, } from "../../../../contexts/properties.context.js";
19
- import { pageDispatchContext, } from "../../../../contexts/events.context.js";
20
+ import { pageDispatchContext, pageHrefContext, } from "../../../../contexts/events.context.js";
20
21
  import styles from "./location-highlights.styles.js";
21
22
  import { renderLoyaltyBadge } from "../../../../components/loyalty-badge/loyalty-badge.utils.js";
22
23
  /**
@@ -74,20 +75,22 @@ let CorasLocationHighlights = class CorasLocationHighlights extends LitElement {
74
75
  });
75
76
  }
76
77
  static { this.styles = styles; }
77
- handleCardClick(card) {
78
- this.dispatchPageUpdate({
78
+ cardTarget(card) {
79
+ return {
79
80
  page: "details",
80
81
  id: card.id,
81
82
  date: formatISO(parseISO(card.date), { representation: "date" }),
82
83
  locale: this.locale,
83
84
  currency: this.currency,
84
- });
85
+ };
85
86
  }
86
87
  renderCard(card) {
87
88
  const price = card.price[this.currency];
89
+ const target = this.cardTarget(card);
88
90
  return html `
89
91
  <coras-attraction-short-card
90
92
  .images=${card.images}
93
+ loading="lazy"
91
94
  ?label=${false}
92
95
  name=${card.title}
93
96
  rating=${card.rating || 0}
@@ -102,7 +105,8 @@ let CorasLocationHighlights = class CorasLocationHighlights extends LitElement {
102
105
  date=${card.date}
103
106
  timezone=${card.timezone}
104
107
  locale=${this.locale}
105
- @click=${() => this.handleCardClick(card)}
108
+ href=${ifDefined(this._pageHref?.(target))}
109
+ @click=${() => this.dispatchPageUpdate(target)}
106
110
  >
107
111
  ${renderLoyaltyBadge({
108
112
  loyalty: card.loyalty,
@@ -166,6 +170,9 @@ __decorate([
166
170
  __decorate([
167
171
  consume({ context: pageDispatchContext })
168
172
  ], CorasLocationHighlights.prototype, "dispatchPageUpdate", void 0);
173
+ __decorate([
174
+ consume({ context: pageHrefContext })
175
+ ], CorasLocationHighlights.prototype, "_pageHref", void 0);
169
176
  CorasLocationHighlights = __decorate([
170
177
  localized()
171
178
  ], CorasLocationHighlights);
@@ -25,9 +25,11 @@ declare const CorasHelpPage_base: import("../../contexts/utils.js").Constructor<
25
25
  loyaltyPoints: boolean;
26
26
  loyaltyProgramme: import("../../index.js").CorasLoyaltyProgramme | null;
27
27
  logger: import("../../core/logger.js").Logger;
28
+ hrefFor: import("../../index.js").CorasHrefFor | null;
28
29
  client: import("openapi-fetch").Client<import("../../core/types/api-schema.js").paths>;
29
30
  getPageProperties(): HelpPageParamsEvent;
30
31
  dispatchPageUpdate(params: import("../../contexts/events.context.js").PageDispatchInput): void;
32
+ pageUpdateHref(params: import("../../contexts/events.context.js").PageDispatchInput): string | undefined;
31
33
  }> & typeof LitElement;
32
34
  /**
33
35
  * Help page component for FAQs, contact form, and policy pages.
@@ -1,5 +1,6 @@
1
1
  import { type CSSResultGroup, LitElement, type PropertyValues } from "lit";
2
2
  import type { LandingPageParamsEvent } from "../../core/pages.js";
3
+ import type { PageDispatchInput } from "../../contexts/events.context.js";
3
4
  import type { PageName } from "../../core/types/shared.js";
4
5
  import "../../components/location-image/location-image.js";
5
6
  import "../../components/dropdown/dropdown.js";
@@ -38,9 +39,11 @@ declare const CorasLandingPage_base: import("../../contexts/utils.js").Construct
38
39
  loyaltyPoints: boolean;
39
40
  loyaltyProgramme: import("../../index.js").CorasLoyaltyProgramme | null;
40
41
  logger: import("../../core/logger.js").Logger;
42
+ hrefFor: import("../../index.js").CorasHrefFor | null;
41
43
  client: import("openapi-fetch").Client<import("../../core/types/api-schema.js").paths>;
42
44
  getPageProperties(): LandingPageParamsEvent;
43
- dispatchPageUpdate(params: import("../../contexts/events.context.js").PageDispatchInput): void;
45
+ dispatchPageUpdate(params: PageDispatchInput): void;
46
+ pageUpdateHref(params: PageDispatchInput): string | undefined;
44
47
  }> & typeof LitElement;
45
48
  /**
46
49
  * @fires coras:navigate