@coras-io/embed 0.11.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 (45) hide show
  1. package/CHANGELOG.md +15 -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 +5 -0
  9. package/dist/components/breadcrumbs/breadcrumb-item/breadcrumb-item.component.js +16 -3
  10. package/dist/components/breadcrumbs/breadcrumb-item/breadcrumb-item.styles.js +3 -1
  11. package/dist/components/image/image.component.d.ts +12 -0
  12. package/dist/components/image/image.component.js +49 -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 +22 -41
  35. package/dist/views/details-page/partials/location-highlights/location-highlights.component.d.ts +2 -1
  36. package/dist/views/details-page/partials/location-highlights/location-highlights.component.js +12 -5
  37. package/dist/views/help-page/help-page.component.d.ts +2 -0
  38. package/dist/views/landing-page/landing-page.component.d.ts +4 -1
  39. package/dist/views/landing-page/landing-page.component.js +21 -16
  40. package/dist/views/payment-page/payment-page.component.d.ts +2 -0
  41. package/dist/views/search-page/search-page.component.d.ts +5 -2
  42. package/dist/views/search-page/search-page.component.js +41 -48
  43. package/dist/views/suggestion-widget/suggestion-widget.component.d.ts +5 -2
  44. package/dist/views/suggestion-widget/suggestion-widget.component.js +7 -4
  45. package/package.json +1 -1
@@ -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.11.0",
23
+ "version": "0.12.0",
24
24
  "private": false,
25
25
  "homepage": "https://docs.coras.io",
26
26
  "bugs": {