@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
@@ -6,6 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  import { html, LitElement, nothing, } from "lit";
8
8
  import { when } from "lit/directives/when.js";
9
+ import { ifDefined } from "lit/directives/if-defined.js";
9
10
  import { property, query, state } from "lit/decorators.js";
10
11
  import { msg, localized } from "@lit/localize";
11
12
  import { Task } from "@lit/task";
@@ -830,6 +831,15 @@ let CorasLandingPage = class CorasLandingPage extends ErrorModalMixin(LocationSe
830
831
 
831
832
  <div class="cards">
832
833
  ${cards.map((card) => {
834
+ const target = {
835
+ locale: this.locale,
836
+ currency: this.currency,
837
+ page: "details",
838
+ id: card.id,
839
+ date: formatISO(parseISO(card.date), {
840
+ representation: "date",
841
+ }),
842
+ };
833
843
  return html `
834
844
  <coras-attraction-short-card
835
845
  .images=${card.images}
@@ -845,15 +855,8 @@ let CorasLandingPage = class CorasLandingPage extends ErrorModalMixin(LocationSe
845
855
  date=${card.date}
846
856
  timezone=${card.timezone}
847
857
  locale=${this.locale}
848
- @click=${() => this.dispatchPageUpdate({
849
- locale: this.locale,
850
- currency: this.currency,
851
- page: "details",
852
- id: card.id,
853
- date: formatISO(parseISO(card.date), {
854
- representation: "date",
855
- }),
856
- })}
858
+ href=${ifDefined(this.pageUpdateHref(target))}
859
+ @click=${() => this.dispatchPageUpdate(target)}
857
860
  >
858
861
  ${renderLoyaltyBadge({
859
862
  loyalty: card.loyalty,
@@ -911,17 +914,19 @@ let CorasLandingPage = class CorasLandingPage extends ErrorModalMixin(LocationSe
911
914
  if (!matchingCity) {
912
915
  return nothing;
913
916
  }
914
- const handleCountryClick = () => {
915
- this.dispatchPageUpdate({
916
- page: "landing",
917
- country: this.resolvedCountry,
918
- city: "",
919
- });
917
+ const countryTarget = {
918
+ page: "landing",
919
+ country: this.resolvedCountry,
920
+ city: "",
920
921
  };
921
922
  return html `
922
923
  <div class="breadcrumbs-container">
923
924
  <coras-breadcrumbs assets-url="${this.assetsURL}">
924
- <coras-breadcrumb-item @click=${handleCountryClick} clickable>
925
+ <coras-breadcrumb-item
926
+ href=${ifDefined(this.pageUpdateHref(countryTarget))}
927
+ @click=${() => this.dispatchPageUpdate(countryTarget)}
928
+ clickable
929
+ >
925
930
  ${matchingCountry.name}
926
931
  </coras-breadcrumb-item>
927
932
  <coras-breadcrumb-item> ${matchingCity.name} </coras-breadcrumb-item>
@@ -39,9 +39,11 @@ declare const CorasPaymentPage_base: import("../../contexts/utils.js").Construct
39
39
  loyaltyPoints: boolean;
40
40
  loyaltyProgramme: import("../../core/utils/loyalty.js").LoyaltyProgramme | null;
41
41
  logger: Logger;
42
+ hrefFor: import("../../index.js").CorasHrefFor | null;
42
43
  client: import("openapi-fetch").Client<import("../../core/types/api-schema.js").paths>;
43
44
  getPageProperties(): PaymentPageParamsEvent;
44
45
  dispatchPageUpdate(params: import("../../contexts/events.context.js").PageDispatchInput): void;
46
+ pageUpdateHref(params: import("../../contexts/events.context.js").PageDispatchInput): string | undefined;
45
47
  }> & typeof LitElement;
46
48
  /**
47
49
  * Payment page component for processing checkout and payments.
@@ -1,4 +1,5 @@
1
1
  import { type CSSResultGroup, LitElement, type PropertyValues } from "lit";
2
+ import type { PageDispatchInput } from "../../contexts/events.context.js";
2
3
  import "../../components/attraction-card/long/attraction-long-card.js";
3
4
  import "../../components/button/button.js";
4
5
  import "../../components/loading-spinner/loading-spinner.js";
@@ -20,9 +21,11 @@ declare const CorasSearchPage_base: import("../../contexts/utils.js").Constructo
20
21
  loyaltyPoints: boolean;
21
22
  loyaltyProgramme: import("../../index.js").CorasLoyaltyProgramme | null;
22
23
  logger: import("../../core/logger.js").Logger;
24
+ hrefFor: import("../../index.js").CorasHrefFor | null;
23
25
  client: Client<paths>;
24
26
  getPageProperties(): SearchPageParamsEvent;
25
- dispatchPageUpdate(params: import("../../contexts/events.context.js").PageDispatchInput): void;
27
+ dispatchPageUpdate(params: PageDispatchInput): void;
28
+ pageUpdateHref(params: PageDispatchInput): string | undefined;
26
29
  }> & typeof LitElement;
27
30
  /**
28
31
  * Search page component for displaying search results.
@@ -58,7 +61,7 @@ export declare class CorasSearchPage extends CorasSearchPage_base {
58
61
  updated(changedProperties: PropertyValues): void;
59
62
  private renderSkeleton;
60
63
  private renderAttractions;
61
- private handleAttractionClick;
64
+ private renderBreadcrumbLink;
62
65
  private renderBottomSection;
63
66
  render(): import("lit").TemplateResult<1>;
64
67
  }
@@ -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, state } from "lit/decorators.js";
9
+ import { ifDefined } from "lit/directives/if-defined.js";
9
10
  import { consume } from "@lit/context";
10
11
  import { msg, str, localized } from "@lit/localize";
11
12
  import { LocationSearchMixin } from "../../mixins/location-search/location-search.js";
@@ -128,36 +129,18 @@ let CorasSearchPage = class CorasSearchPage extends ErrorModalMixin(LocationSear
128
129
  : null;
129
130
  const countryName = country?.name;
130
131
  const countrySlug = country?.slug;
131
- const handleCountryClick = () => {
132
- if (!countrySlug)
133
- return;
134
- this.dispatchPageUpdate({
135
- page: "landing",
136
- country: countrySlug,
137
- city: "",
138
- });
139
- };
140
- const handleCityClick = () => {
141
- if (!countrySlug || !citySlug)
142
- return;
143
- this.dispatchPageUpdate({
144
- page: "landing",
145
- country: countrySlug,
146
- city: citySlug,
147
- });
148
- };
132
+ const countryTarget = countrySlug
133
+ ? { page: "landing", country: countrySlug, city: "" }
134
+ : null;
135
+ const cityTarget = countrySlug && citySlug
136
+ ? { page: "landing", country: countrySlug, city: citySlug }
137
+ : null;
149
138
  return html `
150
139
  <coras-breadcrumbs assets-url="${this.assetsURL}">
151
140
  ${countryName
152
- ? html `<coras-breadcrumb-item @click=${handleCountryClick} clickable>
153
- ${countryName}
154
- </coras-breadcrumb-item>`
155
- : nothing}
156
- ${cityName
157
- ? html `<coras-breadcrumb-item @click=${handleCityClick} clickable>
158
- ${cityName}
159
- </coras-breadcrumb-item>`
141
+ ? this.renderBreadcrumbLink(countryName, countryTarget)
160
142
  : nothing}
143
+ ${cityName ? this.renderBreadcrumbLink(cityName, cityTarget) : nothing}
161
144
  <coras-breadcrumb-item> ${this.search} </coras-breadcrumb-item>
162
145
  </coras-breadcrumbs>
163
146
  `;
@@ -278,7 +261,12 @@ let CorasSearchPage = class CorasSearchPage extends ErrorModalMixin(LocationSear
278
261
  ${this.renderTitle()} ${this.renderBreadcrumbs()}
279
262
 
280
263
  <div class="cards">
281
- ${this.attractions.map((result) => html `
264
+ ${this.attractions.map((result) => {
265
+ const target = {
266
+ page: "details",
267
+ id: result.attraction_id,
268
+ };
269
+ return html `
282
270
  <coras-attraction-long-card
283
271
  .images=${adaptPresetImages(result.images)}
284
272
  ?label=${false}
@@ -286,37 +274,42 @@ let CorasSearchPage = class CorasSearchPage extends ErrorModalMixin(LocationSear
286
274
  rating=${result.rating || 0}
287
275
  category=${result.main_category.slug}
288
276
  price=${convertToLocaleCurrency({
289
- value: result.min_price[this.currency] || 0,
290
- locale: this.locale,
291
- currency: this.currency,
292
- })}
277
+ value: result.min_price[this.currency] || 0,
278
+ locale: this.locale,
279
+ currency: this.currency,
280
+ })}
293
281
  description=${truncate({
294
- text: removeHtmlTags(result.description || ""),
295
- })}
282
+ text: removeHtmlTags(result.description || ""),
283
+ })}
296
284
  date=${result.upcoming_instances[0] ||
297
- formatISO(new Date(), { representation: "date" })}
285
+ formatISO(new Date(), { representation: "date" })}
298
286
  timezone=${result.timezone || ""}
299
287
  locale=${this.locale}
300
- @click=${() => this.handleAttractionClick(result.attraction_id)}
288
+ href=${ifDefined(this.pageUpdateHref(target))}
289
+ @click=${() => this.dispatchPageUpdate(target)}
301
290
  >
302
291
  ${renderLoyaltyBadge({
303
- loyalty: result.loyalty,
304
- programme: this.loyaltyProgramme,
305
- locale: this.locale,
306
- variant: "card",
307
- slot: "points",
308
- from: true,
309
- })}
292
+ loyalty: result.loyalty,
293
+ programme: this.loyaltyProgramme,
294
+ locale: this.locale,
295
+ variant: "card",
296
+ slot: "points",
297
+ from: true,
298
+ })}
310
299
  </coras-attraction-long-card>
311
- `)}
300
+ `;
301
+ })}
312
302
  </div>
313
303
  `;
314
304
  }
315
- handleAttractionClick(attractionId) {
316
- this.dispatchPageUpdate({
317
- page: "details",
318
- id: attractionId,
319
- });
305
+ renderBreadcrumbLink(label, target) {
306
+ return html `<coras-breadcrumb-item
307
+ href=${ifDefined(target ? this.pageUpdateHref(target) : undefined)}
308
+ @click=${() => target && this.dispatchPageUpdate(target)}
309
+ clickable
310
+ >
311
+ ${label}
312
+ </coras-breadcrumb-item>`;
320
313
  }
321
314
  renderBottomSection() {
322
315
  const isLoading = this.attractionsSearchTask.status === TaskStatus.PENDING && this.page > 0;
@@ -4,6 +4,7 @@ import "../../components/button/button.js";
4
4
  import "../../components/carousel/carousel.js";
5
5
  import "../../components/attraction-card/short/attraction-short-card.js";
6
6
  import type { PageParamsEvent } from "../../core/pages.js";
7
+ import type { PageDispatchInput } from "../../contexts/events.context.js";
7
8
  declare const CorasSuggestionWidget_base: import("../../contexts/utils.js").Constructor<{
8
9
  apiHost: string;
9
10
  distributorID: string;
@@ -15,9 +16,11 @@ declare const CorasSuggestionWidget_base: import("../../contexts/utils.js").Cons
15
16
  loyaltyPoints: boolean;
16
17
  loyaltyProgramme: import("../../index.js").CorasLoyaltyProgramme | null;
17
18
  logger: import("../../core/logger.js").Logger;
19
+ hrefFor: import("../../index.js").CorasHrefFor | null;
18
20
  client: import("openapi-fetch").Client<import("../../core/types/api-schema.js").paths>;
19
21
  getPageProperties(): PageParamsEvent;
20
- dispatchPageUpdate(params: import("../../contexts/events.context.js").PageDispatchInput): void;
22
+ dispatchPageUpdate(params: PageDispatchInput): void;
23
+ pageUpdateHref(params: PageDispatchInput): string | undefined;
21
24
  }> & typeof LitElement;
22
25
  export declare class CorasSuggestionWidget extends CorasSuggestionWidget_base {
23
26
  static styles: CSSResultGroup;
@@ -29,7 +32,7 @@ export declare class CorasSuggestionWidget extends CorasSuggestionWidget_base {
29
32
  /** Turn a location slug ("gran-canaria") into a display name ("Gran Canaria"). */
30
33
  private humanize;
31
34
  private suggestionsTask;
32
- private handleCardClick;
35
+ private cardTarget;
33
36
  private handleExploreCardClick;
34
37
  private renderCard;
35
38
  private renderExploreCard;
@@ -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 { localized, msg, str } from "@lit/localize";
10
11
  import { Task } from "@lit/task";
11
12
  import { formatISO, parseISO } from "date-fns";
@@ -60,14 +61,14 @@ let CorasSuggestionWidget = class CorasSuggestionWidget extends BaseMixin(LitEle
60
61
  .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
61
62
  .join(" ");
62
63
  }
63
- handleCardClick(card) {
64
- this.dispatchPageUpdate({
64
+ cardTarget(card) {
65
+ return {
65
66
  page: "details",
66
67
  id: card.id,
67
68
  date: formatISO(parseISO(card.date), { representation: "date" }),
68
69
  locale: this.locale,
69
70
  currency: this.currency,
70
- });
71
+ };
71
72
  }
72
73
  handleExploreCardClick(country, city) {
73
74
  this.dispatchPageUpdate({
@@ -80,6 +81,7 @@ let CorasSuggestionWidget = class CorasSuggestionWidget extends BaseMixin(LitEle
80
81
  }
81
82
  renderCard(card) {
82
83
  const price = card.price[this.currency];
84
+ const target = this.cardTarget(card);
83
85
  return html `
84
86
  <coras-attraction-short-card
85
87
  .images=${card.images}
@@ -97,7 +99,8 @@ let CorasSuggestionWidget = class CorasSuggestionWidget extends BaseMixin(LitEle
97
99
  date=${card.date}
98
100
  timezone=${card.timezone}
99
101
  locale=${this.locale}
100
- @click=${() => this.handleCardClick(card)}
102
+ href=${ifDefined(this.pageUpdateHref(target))}
103
+ @click=${() => this.dispatchPageUpdate(target)}
101
104
  >
102
105
  ${renderLoyaltyBadge({
103
106
  loyalty: card.loyalty,
package/package.json CHANGED
@@ -20,7 +20,7 @@
20
20
  "engines": {
21
21
  "node": ">=22"
22
22
  },
23
- "version": "0.10.0",
23
+ "version": "0.12.0",
24
24
  "private": false,
25
25
  "homepage": "https://docs.coras.io",
26
26
  "bugs": {