@geotrekce/geotrek-rando-widget 0.0.5 → 0.0.8

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 (62) hide show
  1. package/dist/cjs/geotrek-rando-widget.cjs.js +2 -2
  2. package/dist/cjs/grw-app.cjs.entry.js +38 -11
  3. package/dist/cjs/grw-filter_6.cjs.entry.js +141 -71
  4. package/dist/cjs/grw-information-desk-detail_3.cjs.entry.js +3 -3
  5. package/dist/cjs/grw-trek-card.cjs.entry.js +3 -3
  6. package/dist/cjs/{index-c2c4531d.js → index-4c76daa3.js} +8 -3
  7. package/dist/cjs/loader.cjs.js +2 -2
  8. package/dist/cjs/{store-972b8d2a.js → store-b4c3c507.js} +7 -3
  9. package/dist/collection/components/grw-app/grw-app.css +17 -11
  10. package/dist/collection/components/grw-app/grw-app.js +45 -15
  11. package/dist/collection/components/grw-filter/grw-filter.js +11 -12
  12. package/dist/collection/components/grw-map/grw-map.js +41 -22
  13. package/dist/collection/components/grw-sensitive-area-detail/grw-sensitive-area-detail.css +1 -0
  14. package/dist/collection/components/grw-trek-card/grw-trek-card.js +1 -1
  15. package/dist/collection/components/grw-trek-detail/grw-trek-detail.css +6 -0
  16. package/dist/collection/components/grw-trek-detail/grw-trek-detail.js +21 -5
  17. package/dist/collection/components/grw-treks-list/grw-treks-list.css +0 -12
  18. package/dist/collection/components/grw-treks-list/grw-treks-list.js +21 -9
  19. package/dist/collection/store/grw-trek-provider.js +28 -15
  20. package/dist/collection/store/grw-treks-provider.js +17 -8
  21. package/dist/collection/store/store.js +6 -2
  22. package/dist/components/grw-app.js +38 -11
  23. package/dist/components/grw-filter2.js +11 -12
  24. package/dist/components/grw-map2.js +41 -22
  25. package/dist/components/grw-sensitive-area-detail2.js +1 -1
  26. package/dist/components/grw-trek-card2.js +1 -1
  27. package/dist/components/grw-trek-detail2.js +20 -4
  28. package/dist/components/grw-trek-provider2.js +28 -15
  29. package/dist/components/grw-treks-list2.js +23 -9
  30. package/dist/components/grw-treks-provider2.js +17 -8
  31. package/dist/components/store.js +6 -2
  32. package/dist/esm/geotrek-rando-widget.js +2 -2
  33. package/dist/esm/grw-app.entry.js +38 -11
  34. package/dist/esm/grw-filter_6.entry.js +141 -71
  35. package/dist/esm/grw-information-desk-detail_3.entry.js +3 -3
  36. package/dist/esm/grw-trek-card.entry.js +3 -3
  37. package/dist/esm/{index-192d910f.js → index-ee473772.js} +8 -3
  38. package/dist/esm/loader.js +2 -2
  39. package/dist/esm/{store-5a42b5d8.js → store-a5f523fd.js} +7 -3
  40. package/dist/geotrek-rando-widget/geotrek-rando-widget.esm.js +1 -1
  41. package/dist/geotrek-rando-widget/{p-d3aa9819.entry.js → p-0510e16b.entry.js} +1 -1
  42. package/dist/geotrek-rando-widget/p-22562f4d.js +1 -0
  43. package/dist/geotrek-rando-widget/{p-2d9ae918.entry.js → p-500436f1.entry.js} +1 -1
  44. package/dist/geotrek-rando-widget/p-94f0db4d.entry.js +1 -0
  45. package/dist/geotrek-rando-widget/p-9a25f817.entry.js +1 -0
  46. package/dist/geotrek-rando-widget/p-b62909db.js +2 -0
  47. package/dist/types/components/grw-app/grw-app.d.ts +3 -3
  48. package/dist/types/components/grw-filter/grw-filter.d.ts +1 -1
  49. package/dist/types/components/grw-map/grw-map.d.ts +3 -2
  50. package/dist/types/components/grw-trek-card/grw-trek-card.d.ts +1 -1
  51. package/dist/types/components/grw-trek-detail/grw-trek-detail.d.ts +1 -1
  52. package/dist/types/components/grw-treks-list/grw-treks-list.d.ts +3 -2
  53. package/dist/types/components.d.ts +2 -2
  54. package/dist/types/store/grw-trek-provider.d.ts +4 -1
  55. package/dist/types/store/grw-treks-provider.d.ts +4 -1
  56. package/dist/types/store/store.d.ts +9 -0
  57. package/package.json +1 -1
  58. package/readme.md +4 -0
  59. package/dist/geotrek-rando-widget/p-206a52d9.entry.js +0 -1
  60. package/dist/geotrek-rando-widget/p-6dce5e6c.js +0 -2
  61. package/dist/geotrek-rando-widget/p-8cfa03c0.entry.js +0 -1
  62. package/dist/geotrek-rando-widget/p-e63213a9.js +0 -1
@@ -6,30 +6,42 @@ export class GrwTreksList {
6
6
  this.colorPrimary = '#6b0030';
7
7
  this.colorPrimaryTint = '#974c6e';
8
8
  this.isLargeView = false;
9
- this.handleInfiniteScrollBind = this.handleInfiniteScroll.bind(this);
10
9
  this.step = 10;
10
+ this.handleInfiniteScrollBind = this.handleInfiniteScroll.bind(this);
11
11
  }
12
- componentWillLoad() {
12
+ connectedCallback() {
13
+ this.element.addEventListener('scroll', this.handleInfiniteScrollBind);
14
+ if (state.currentTreks) {
15
+ this.treksToDisplay = [...state.currentTreks.slice(0, this.step)];
16
+ }
13
17
  onChange('currentTreks', () => {
14
- this.element.addEventListener('scroll', this.handleInfiniteScrollBind);
15
18
  this.element.scroll({ top: 0 });
16
- this.treksToDisplay = [...state.currentTreks.slice(0, this.step)];
19
+ if (state.currentTreks) {
20
+ this.treksToDisplay = [...state.currentTreks.slice(0, this.step)];
21
+ }
22
+ });
23
+ onChange('treksWithinBounds', () => {
24
+ this.element.scroll({ top: 0 });
25
+ if (state.treksWithinBounds) {
26
+ this.treksToDisplay = [...state.treksWithinBounds.slice(0, this.step)];
27
+ }
17
28
  });
18
29
  }
19
30
  handleInfiniteScroll(event) {
20
31
  if (event.composedPath()[0].scrollTop + event.composedPath()[0].scrollHeight / 2 >= event.composedPath()[0].scrollHeight) {
21
- if (this.treksToDisplay.length < state.treks.length) {
22
- this.treksToDisplay = state.currentTreks.slice(0, this.treksToDisplay.length + this.step >= state.currentTreks.length ? state.currentTreks.length : this.treksToDisplay.length + this.step);
32
+ if (this.treksToDisplay.length < state.treksWithinBounds.length) {
33
+ this.treksToDisplay = state.treksWithinBounds.slice(0, this.treksToDisplay.length + this.step >= state.treksWithinBounds.length ? state.treksWithinBounds.length : this.treksToDisplay.length + this.step);
23
34
  }
24
35
  else {
25
36
  this.element.removeEventListener('scroll', this.handleInfiniteScrollBind);
26
37
  }
27
38
  }
28
39
  }
40
+ disconnectedCallback() {
41
+ this.element.removeEventListener('scroll', this.handleInfiniteScrollBind);
42
+ }
29
43
  render() {
30
- return (h(Host, { style: { '--color-primary': this.colorPrimary, '--color-primary-tint': this.colorPrimaryTint } },
31
- h("div", { class: "current-treks-length" }, `${state.currentTreks.length} résultat${state.currentTreks.length > 1 ? 's' : ''}`),
32
- h("div", { class: "current-treks-container" }, this.treksToDisplay.map(trek => (h("grw-trek-card", { key: `trek-${trek.id}`, trek: trek, "is-large-view": this.isLargeView, "color-primary": this.colorPrimary, "color-primary-tint": this.colorPrimaryTint }))))));
44
+ return (h(Host, { style: { '--color-primary': this.colorPrimary, '--color-primary-tint': this.colorPrimaryTint } }, this.treksToDisplay.map(trek => (h("grw-trek-card", { key: `trek-${trek.id}`, trek: trek, "is-large-view": this.isLargeView, "color-primary": this.colorPrimary, "color-primary-tint": this.colorPrimaryTint })))));
33
45
  }
34
46
  static get is() { return "grw-treks-list"; }
35
47
  static get encapsulation() { return "shadow"; }
@@ -3,27 +3,33 @@ import state from 'store/store';
3
3
  export class GrwTrekProvider {
4
4
  constructor() {
5
5
  this.language = 'fr';
6
+ this.trekNetworkError = false;
7
+ this.controller = new AbortController();
8
+ this.signal = this.controller.signal;
6
9
  }
7
- componentWillLoad() {
10
+ connectedCallback() {
8
11
  state.api = this.api;
9
12
  const requests = [];
10
- requests.push(!state.difficulties ? fetch(`${this.api}trek_difficulty/?language=${this.language}&fields=id,label,pictogram`) : new Response('null'));
11
- requests.push(!state.routes ? fetch(`${this.api}trek_route/?language=${this.language}&fields=id,route,pictogram`) : new Response('null'));
12
- requests.push(!state.practices ? fetch(`${this.api}trek_practice/?language=${this.language}&fields=id,name,pictogram`) : new Response('null'));
13
- requests.push(!state.themes ? fetch(`${this.api}theme/?language=${this.language}&fields=id,label,pictogram`) : new Response('null'));
14
- return Promise.all([
13
+ requests.push(!state.difficulties ? fetch(`${this.api}trek_difficulty/?language=${this.language}&fields=id,label,pictogram`, { signal: this.signal }) : new Response('null'));
14
+ requests.push(!state.routes ? fetch(`${this.api}trek_route/?language=${this.language}&fields=id,route,pictogram`, { signal: this.signal }) : new Response('null'));
15
+ requests.push(!state.practices ? fetch(`${this.api}trek_practice/?language=${this.language}&fields=id,name,pictogram`, { signal: this.signal }) : new Response('null'));
16
+ requests.push(!state.themes ? fetch(`${this.api}theme/?language=${this.language}&fields=id,label,pictogram`, { signal: this.signal }) : new Response('null'));
17
+ Promise.all([
15
18
  ...requests,
16
- fetch(`${this.api}sensitivearea/?language=${this.language}&published=true&trek=${this.trekId}&fields=id,geometry,name,description,contact,info_url,period,practices`).catch(() => new Response('null')),
17
- fetch(`${this.api}label/?language=${this.language}&fields=id,name,advice,pictogram`),
18
- fetch(`${this.api}source/?language=${this.language}&fields=id,name,website,pictogram`),
19
- fetch(`${this.api}trek_accessibility/?language=${this.language}&fields=id,name,pictogram`),
20
- fetch(`${this.api}trek_accessibility_level/?language=${this.language}&fields=id,name`),
21
- fetch(`${this.api}poi/?language=${this.language}&trek=${this.trekId}&published=true&fields=id,name,description,attachments,type,type_label,type_pictogram,url,published,geometry&page_size=999`),
22
- fetch(`${this.api}informationdesk/?language=${this.language}&near_trek=${this.trekId}&fields=id,name,description,type,phone,email,website,municipality,postal_code,street,photo_url,latitude,longitude&page_size=999`),
23
- fetch(`${this.api}trek/${this.trekId}/?language=${this.language}&published=true&fields=id,name,attachments,description,description_teaser,difficulty,duration,ascent,length_2d,practice,themes,route,geometry,gpx,kml,pdf,parking_location,departure,arrival,altimetric_profile,ambiance,access,public_transport,advice,advised_parking,gear,labels,source,points_reference,disabled_infrastructure,accessibility_level,accessibility_slope,accessibility_width,accessibility_signage,accessibility_covering,accessibility_exposure,accessibility_advice,accessibilities`),
19
+ fetch(`${this.api}sensitivearea/?language=${this.language}&published=true&trek=${this.trekId}&fields=id,geometry,name,description,contact,info_url,period,practices`, {
20
+ signal: this.signal,
21
+ }).catch(() => new Response('null')),
22
+ fetch(`${this.api}label/?language=${this.language}&fields=id,name,advice,pictogram`, { signal: this.signal }),
23
+ fetch(`${this.api}source/?language=${this.language}&fields=id,name,website,pictogram`, { signal: this.signal }),
24
+ fetch(`${this.api}trek_accessibility/?language=${this.language}&fields=id,name,pictogram`, { signal: this.signal }),
25
+ fetch(`${this.api}trek_accessibility_level/?language=${this.language}&fields=id,name`, { signal: this.signal }).catch(() => new Response('null')),
26
+ fetch(`${this.api}poi/?language=${this.language}&trek=${this.trekId}&published=true&fields=id,name,description,attachments,type,type_label,type_pictogram,url,published,geometry&page_size=999`, { signal: this.signal }),
27
+ fetch(`${this.api}informationdesk/?language=${this.language}&near_trek=${this.trekId}&fields=id,name,description,type,phone,email,website,municipality,postal_code,street,photo_url,latitude,longitude&page_size=999`, { signal: this.signal }),
28
+ fetch(`${this.api}trek/${this.trekId}/?language=${this.language}&published=true&fields=id,name,attachments,description,description_teaser,difficulty,duration,ascent,length_2d,practice,themes,route,geometry,gpx,kml,pdf,parking_location,departure,arrival,altimetric_profile,ambiance,access,public_transport,advice,advised_parking,gear,labels,source,points_reference,disabled_infrastructure,accessibility_level,accessibility_slope,accessibility_width,accessibility_signage,accessibility_covering,accessibility_exposure,accessibility_advice,accessibilities`, { signal: this.signal }),
24
29
  ])
25
30
  .then(responses => Promise.all(responses.map(response => response.json())))
26
31
  .then(([difficulties, routes, practices, themes, sensitiveAreas, labels, sources, accessibilities, accessibilitiesLevel, pois, informationDesks, trek]) => {
32
+ state.trekNetworkError = false;
27
33
  if (difficulties) {
28
34
  state.difficulties = difficulties.results;
29
35
  }
@@ -42,14 +48,21 @@ export class GrwTrekProvider {
42
48
  state.labels = labels.results;
43
49
  state.sources = sources.results;
44
50
  state.accessibilities = accessibilities.results;
45
- state.accessibilitiesLevel = accessibilitiesLevel.results;
51
+ if (accessibilitiesLevel) {
52
+ state.accessibilitiesLevel = accessibilitiesLevel.results;
53
+ }
46
54
  state.currentPois = pois.results;
47
55
  state.currentInformationDesks = informationDesks.results;
48
56
  state.currentTrek = trek;
57
+ })
58
+ .catch(() => {
59
+ state.trekNetworkError = true;
49
60
  });
50
61
  }
51
62
  disconnectedCallback() {
63
+ this.controller.abort();
52
64
  state.currentTrek = null;
65
+ state.trekNetworkError = false;
53
66
  }
54
67
  render() {
55
68
  return h(Host, null);
@@ -3,8 +3,10 @@ import state from 'store/store';
3
3
  export class GrwTreksProvider {
4
4
  constructor() {
5
5
  this.language = 'fr';
6
+ this.controller = new AbortController();
7
+ this.signal = this.controller.signal;
6
8
  }
7
- componentWillLoad() {
9
+ connectedCallback() {
8
10
  state.api = this.api;
9
11
  let treksRequest = `${this.api}trek/?language=${this.language}&published=true`;
10
12
  this.inBbox && (treksRequest += `&in_bbox=${this.inBbox}`);
@@ -16,15 +18,16 @@ export class GrwTreksProvider {
16
18
  this.routes && (treksRequest += `&routes=${this.routes}`);
17
19
  this.practices && (treksRequest += `&practices=${this.practices}`);
18
20
  treksRequest += `&fields=id,name,attachments,description_teaser,difficulty,duration,ascent,length_2d,practice,themes,route,departure,departure_geom&page_size=999`;
19
- return Promise.all([
20
- fetch(`${this.api}trek_difficulty/?language=${this.language}&fields=id,label,pictogram`),
21
- fetch(`${this.api}trek_route/?language=${this.language}&fields=id,route,pictogram`),
22
- fetch(`${this.api}trek_practice/?language=${this.language}&fields=id,name,pictogram`),
23
- fetch(`${this.api}theme/?language=${this.language}&fields=id,label,pictogram`),
24
- fetch(treksRequest),
21
+ Promise.all([
22
+ fetch(`${this.api}trek_difficulty/?language=${this.language}&fields=id,label,pictogram`, { signal: this.signal }),
23
+ fetch(`${this.api}trek_route/?language=${this.language}&fields=id,route,pictogram`, { signal: this.signal }),
24
+ fetch(`${this.api}trek_practice/?language=${this.language}&fields=id,name,pictogram`, { signal: this.signal }),
25
+ fetch(`${this.api}theme/?language=${this.language}&fields=id,label,pictogram`, { signal: this.signal }),
26
+ fetch(treksRequest, { signal: this.signal }),
25
27
  ])
26
28
  .then(responses => Promise.all(responses.map(response => response.json())))
27
29
  .then(([difficulties, routes, practices, themes, treks]) => {
30
+ state.treksNetworkError = false;
28
31
  state.difficulties = difficulties.results;
29
32
  state.routes = routes.results;
30
33
  state.practices = practices.results.map(practice => (Object.assign(Object.assign({}, practice), { selected: false })));
@@ -37,7 +40,13 @@ export class GrwTreksProvider {
37
40
  ];
38
41
  state.treks = treks.results;
39
42
  state.currentTreks = treks.results;
40
- });
43
+ state.treksWithinBounds = treks.results;
44
+ })
45
+ .catch(() => (state.treksNetworkError = true));
46
+ }
47
+ disconnectedCallback() {
48
+ this.controller.abort();
49
+ state.treksNetworkError = false;
41
50
  }
42
51
  render() {
43
52
  return h(Host, null);
@@ -1,8 +1,10 @@
1
1
  import { createStore } from '@stencil/store';
2
2
  const { state, onChange } = createStore({
3
3
  api: '',
4
- treks: [],
5
- currentTreks: [],
4
+ treks: null,
5
+ currentTreks: null,
6
+ treksWithinBounds: null,
7
+ currentMapTreksBounds: null,
6
8
  difficulties: [],
7
9
  routes: [],
8
10
  practices: [],
@@ -16,6 +18,8 @@ const { state, onChange } = createStore({
16
18
  currentTrek: null,
17
19
  currentPois: null,
18
20
  currentInformationDesks: null,
21
+ treksNetworkError: false,
22
+ trekNetworkError: false,
19
23
  });
20
24
  export { onChange };
21
25
  export default state;
@@ -1,5 +1,5 @@
1
1
  import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
2
- import { s as state } from './store.js';
2
+ import { o as onChange, s as state } from './store.js';
3
3
  import { d as defineCustomElement$b } from './grw-filter2.js';
4
4
  import { d as defineCustomElement$a } from './grw-information-desk-detail2.js';
5
5
  import { d as defineCustomElement$9 } from './grw-map2.js';
@@ -13,7 +13,7 @@ import { d as defineCustomElement$2 } from './grw-treks-provider2.js';
13
13
 
14
14
  const arrowBackImage = `<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 512 512"><polyline points="244 400 100 256 244 112" style="fill:none;stroke:#ffffff;stroke-linecap:round;stroke-linejoin:round;stroke-width:48px"/><line x1="120" y1="256" x2="412" y2="256" style="fill:none;stroke:#ffffff;stroke-linecap:round;stroke-linejoin:round;stroke-width:48px"/></svg>`;
15
15
 
16
- const grwAppCss = ".app-container{position:relative;height:100%;max-height:100vh;font-family:\"Roboto\"}.header-container,.large-view-header-container{display:flex;align-items:center;background-color:var(--color-primary);height:64px}.header-container .arrow-back-icon,.large-view-header-container .arrow-back-icon{width:48px;height:auto;margin-left:24px}.header-container .arrow-back-icon svg,.large-view-header-container .arrow-back-icon svg{cursor:pointer;width:48px;height:auto}.header-container .handle-filters-button,.large-view-header-container .handle-filters-button{user-select:none;cursor:pointer;color:var(--color-primary);background-color:#ffffff;margin-left:36px;border-radius:8px;padding:8px}.header-container .attribution-container,.large-view-header-container .attribution-container{position:absolute;right:24px}.header-container .attribution-container a,.large-view-header-container .attribution-container a{color:#ffffff;text-decoration:none}.options-container{height:calc(100% - 64px);position:absolute;width:100%;z-index:1100;top:64px}.filters-container{position:absolute;width:100%;background-color:#ffffff;padding:36px 0px;z-index:1100}.filters-container .close-filters-button{cursor:pointer;font-weight:bold;position:absolute;top:12px;right:12px;padding:12px;border-radius:12px;color:var(--color-primary);border:1px var(--color-primary) solid}.filters-container .close-filters-button:hover{background-color:var(--color-primary);color:#ffffff}.filters-container .filter-margin-top{margin-top:24px}.filters-container .current-treks-length{margin:0px 0px 32px 8px;color:var(--color-primary);font-size:24px;font-weight:bold}.back-filters-container{background-color:rgba(0, 0, 0, 0.5);width:100%;height:calc(100% - 64px);position:absolute;z-index:1099;top:64px}.loader-container,.large-view-loader-container{display:flex;justify-content:center;align-items:center;height:100%}.loader-container .loader,.large-view-loader-container .loader{width:48px;height:48px;border:5px solid var(--color-primary-tint);border-bottom-color:var(--color-primary);border-radius:50%;display:inline-block;box-sizing:border-box;animation:rotation 1s linear infinite}@keyframes rotation{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.content-container{position:relative;display:flex;height:calc(100% - 64px)}.app-treks-list-container,.app-trek-detail-container,.large-view-app-treks-list-container,.large-view-app-trek-detail-container{height:100%}.app-map-container,.large-view-app-map-container{width:100%;height:100%}.map-visibility-button{cursor:pointer;display:flex;justify-content:center;align-items:center;position:absolute;bottom:24px;width:100%;z-index:400;user-select:none}.map-visibility-button div{background-color:var(--color-primary);color:#ffffff;padding:12px;border-radius:24px;width:120px;text-align:center}.header-container .title{font-size:24px}.loader-container{position:absolute;width:100%}.app-treks-list-container,.app-trek-detail-container{width:100%}.app-map-container{position:relative;width:100%;position:absolute}.large-view-header-container .title{font-size:32px}.large-view-loader-container{position:relative;width:50%}.large-view-app-treks-list-container,.large-view-app-trek-detail-container{width:50%}.large-view-app-map-container{position:relative;width:50%}";
16
+ const grwAppCss = ".app-container{position:relative;height:100%;max-height:100vh;font-family:\"Roboto\"}.header-container,.large-view-header-container{display:flex;flex-direction:row;align-items:center;background-color:var(--color-primary);height:64px}.header-container .arrow-back-icon,.large-view-header-container .arrow-back-icon{width:48px;height:auto;margin-left:24px}.header-container .arrow-back-icon svg,.large-view-header-container .arrow-back-icon svg{cursor:pointer;width:48px;height:auto}.header-container .handle-filters-container,.large-view-header-container .handle-filters-container{display:flex;align-items:center}.header-container .handle-filters-container .handle-filters-button,.large-view-header-container .handle-filters-container .handle-filters-button{user-select:none;cursor:pointer;color:var(--color-primary);background-color:#ffffff;margin-left:12px;border-radius:8px;padding:8px}.header-container .handle-filters-container .current-treks-within-bounds-length,.large-view-header-container .handle-filters-container .current-treks-within-bounds-length{margin-left:12px;color:#ffffff}.header-container .attribution-container,.large-view-header-container .attribution-container{position:absolute;right:24px}.header-container .attribution-container a,.large-view-header-container .attribution-container a{color:#ffffff;text-decoration:none}.options-container{height:calc(100% - 64px);position:absolute;width:100%;z-index:1100;top:64px}.filters-container{position:absolute;width:100%;background-color:#ffffff;padding:36px 0px;z-index:1100}.filters-container .close-filters-button{cursor:pointer;font-weight:bold;position:absolute;top:12px;right:12px;padding:12px;border-radius:12px;color:var(--color-primary);border:1px var(--color-primary) solid}.filters-container .close-filters-button:hover{background-color:var(--color-primary);color:#ffffff}.filters-container .filter-margin-top{margin-top:24px}.back-filters-container{background-color:rgba(0, 0, 0, 0.5);width:100%;height:calc(100% - 64px);position:absolute;z-index:1099;top:64px}.init-loader-container,.loader-container,.large-view-loader-container{display:flex;justify-content:center;align-items:center;height:100%}.init-loader-container .loader,.loader-container .loader,.large-view-loader-container .loader{width:48px;height:48px;border:5px solid var(--color-primary-tint);border-bottom-color:var(--color-primary);border-radius:50%;display:inline-block;box-sizing:border-box;animation:rotation 1s linear infinite}@keyframes rotation{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.content-container{position:relative;display:flex;height:calc(100% - 64px)}.app-treks-list-container,.app-trek-detail-container,.large-view-app-treks-list-container,.large-view-app-trek-detail-container{height:100%}.app-map-container,.large-view-app-map-container{width:100%;height:100%}.map-visibility-button{cursor:pointer;display:flex;justify-content:center;align-items:center;position:absolute;bottom:24px;width:100%;z-index:400;user-select:none}.map-visibility-button div{background-color:var(--color-primary);color:#ffffff;padding:12px;border-radius:24px;width:120px;text-align:center}.header-container .title{font-size:24px}.init-loader-container,.loader-container{width:100%}.app-treks-list-container,.app-trek-detail-container{width:100%}.app-map-container{position:relative;width:100%;position:absolute}.large-view-header-container .title{font-size:32px}.large-view-loader-container{width:50%}.large-view-app-treks-list-container,.large-view-app-trek-detail-container{width:50%}.large-view-app-map-container{position:relative;width:50%}";
17
17
 
18
18
  const GrwApp$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
19
19
  constructor() {
@@ -34,8 +34,8 @@ const GrwApp$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
34
34
  this.colorArrivalIcon = '#85003b';
35
35
  this.colorSensitiveArea = '#4974a5';
36
36
  this.colorPoiIcon = '#974c6e';
37
- this.handlePopStateBind = this.handlePopState.bind(this);
38
37
  this.largeViewSize = 1024;
38
+ this.handlePopStateBind = this.handlePopState.bind(this);
39
39
  }
40
40
  onTrekCardPress(event) {
41
41
  this.currentTrekId = event.detail;
@@ -51,11 +51,26 @@ const GrwApp$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
51
51
  window.dispatchEvent(new window.Event('resize'));
52
52
  }
53
53
  componentDidLoad() {
54
+ onChange('trekNetworkError', () => {
55
+ if (state.trekNetworkError) {
56
+ const urlRedirect = new URL(window.location.toString());
57
+ urlRedirect.searchParams.delete('trek');
58
+ window.history.replaceState({}, '', urlRedirect);
59
+ this.onTrekDetailsClose();
60
+ }
61
+ });
54
62
  this.handleView();
55
63
  window.addEventListener('popstate', this.handlePopStateBind, false);
64
+ const url = new URL(window.location.toString());
65
+ const trekParam = url.searchParams.get('trek');
66
+ if (trekParam) {
67
+ window.history.replaceState({ isInitialHistoryWithTrek: true }, '', url);
68
+ this.currentTrekId = Number(trekParam);
69
+ this.showTrek = !this.showTrek;
70
+ }
56
71
  }
57
72
  onTrekDetailsClose() {
58
- this.forwardTrekId = this.currentTrekId;
73
+ state.currentTrek = null;
59
74
  this.currentTrekId = null;
60
75
  this.showTrek = !this.showTrek;
61
76
  }
@@ -67,15 +82,27 @@ const GrwApp$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
67
82
  handleFilters() {
68
83
  this.showFilters = !this.showFilters;
69
84
  }
70
- handlePopState() {
71
- if (this.showTrek) {
85
+ handleBackButton() {
86
+ if (window.history.state.isInitialHistoryWithTrek) {
72
87
  this.onTrekDetailsClose();
88
+ const url = new URL(window.location.toString());
89
+ url.searchParams.delete('trek');
90
+ window.history.pushState({}, '', url);
73
91
  }
74
- else if (this.forwardTrekId) {
75
- this.currentTrekId = this.forwardTrekId;
76
- this.forwardTrekId = null;
92
+ else {
93
+ window.history.back();
94
+ }
95
+ }
96
+ handlePopState() {
97
+ const url = new URL(window.location.toString());
98
+ const trekParam = url.searchParams.get('trek');
99
+ if (trekParam) {
100
+ this.currentTrekId = Number(trekParam);
77
101
  this.showTrek = !this.showTrek;
78
102
  }
103
+ else {
104
+ this.onTrekDetailsClose();
105
+ }
79
106
  }
80
107
  handleShowMap() {
81
108
  if (this.currentTrekId) {
@@ -89,7 +116,7 @@ const GrwApp$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
89
116
  window.removeEventListener('popstate', this.handlePopStateBind);
90
117
  }
91
118
  render() {
92
- return (h(Host, { style: { '--color-primary': this.colorPrimary, '--color-primary-tint': this.colorPrimaryTint, '--color-primary-shade': this.colorPrimaryShade } }, h("grw-treks-provider", { api: this.api, language: this.language, "in-bbox": this.inBbox, cities: this.cities, districts: this.districts, structures: this.structures, themes: this.themes, portals: this.portals, routes: this.routes, practices: this.practices }), this.showTrek && this.currentTrekId && h("grw-trek-provider", { api: state.api, language: this.language, "trek-id": this.currentTrekId }), h("div", { class: "app-container" }, h("div", { class: this.isLargeView ? 'large-view-header-container' : 'header-container' }, this.showTrek ? (h("div", { onClick: () => window.history.back(), class: "arrow-back-icon", innerHTML: arrowBackImage })) : (h("div", { onClick: () => this.handleFilters(), class: "handle-filters-button" }, "FILTRER")), !this.showTrek && this.showFilters && (h("div", { class: "options-container" }, h("div", { class: "filters-container" }, h("div", { class: "current-treks-length" }, `${state.currentTreks.length} résultat${state.currentTreks.length > 1 ? 's' : ''}`), h("div", { onClick: () => this.handleFilters(), class: "close-filters-button" }, "X"), h("div", null, h("grw-filter", { filterName: "Pratique", filterType: "practices", filterNameProperty: "name" })), h("div", { class: "filter-margin-top" }, h("grw-filter", { filterName: "Difficult\u00E9", filterType: "difficulties", filterNameProperty: "label" })), h("div", { class: "filter-margin-top" }, h("grw-filter", { filterName: "Dur\u00E9e", filterType: "durations", filterNameProperty: "name" }))), h("div", { onClick: () => this.handleFilters(), class: "back-filters-container" }))), h("div", { class: "attribution-container" }, h("a", { target: "_blank", href: "https://geotrek.fr" }, "GEOTREK"))), h("div", { class: "content-container" }, h("div", { class: this.isLargeView ? 'large-view-app-treks-list-container' : 'app-treks-list-container', style: { display: this.showTrek ? 'none' : 'flex', position: this.showTrek ? 'absolute' : 'relative' } }, h("grw-treks-list", { "is-large-view": this.isLargeView, "color-primary": this.colorPrimary, "color-primary-tint": this.colorPrimaryTint })), this.showTrek && !state.currentTrek && (h("div", { class: this.isLargeView ? 'large-view-loader-container' : 'loader-container' }, h("span", { class: "loader" }))), state.currentTrek && (h("div", { class: this.isLargeView ? 'large-view-app-trek-detail-container' : 'app-trek-detail-container' }, h("grw-trek-detail", { "color-primary": this.colorPrimary, "color-primary-shade": this.colorPrimaryShade, "color-primary-tint": this.colorPrimaryTint }))), h("grw-map", { class: this.isLargeView ? 'large-view-app-map-container' : 'app-map-container', style: { visibility: (this.showTreksMap && !this.showTrek) || (this.showTrekMap && this.showTrek) ? 'visible' : 'hidden' }, "url-layer": this.urlLayer, center: this.center, zoom: this.zoom, attribution: this.attribution, "color-primary": this.colorPrimary, "color-primary-tint": this.colorPrimaryTint, "color-trek-line": this.colorTrekLine, "color-departure-icon": this.colorDepartureIcon, "color-arrival-icon": this.colorArrivalIcon, "color-sensitive-area": this.colorSensitiveArea, "color-poi-icon": this.colorPoiIcon })), h("div", { class: "map-visibility-button", style: { display: this.isLargeView ? 'none' : 'flex' } }, h("div", { onClick: () => this.handleShowMap() }, this.showTreksMap || this.showTrekMap ? (this.showTrek ? 'Voir la fiche' : 'Voir la liste') : 'Voir la carte')))));
119
+ return (h(Host, { style: { '--color-primary': this.colorPrimary, '--color-primary-tint': this.colorPrimaryTint, '--color-primary-shade': this.colorPrimaryShade } }, h("grw-treks-provider", { api: this.api, language: this.language, "in-bbox": this.inBbox, cities: this.cities, districts: this.districts, structures: this.structures, themes: this.themes, portals: this.portals, routes: this.routes, practices: this.practices }), !state.currentTreks && !state.currentTrek && (h("div", { class: "init-loader-container" }, h("span", { class: "loader" }))), this.showTrek && this.currentTrekId && h("grw-trek-provider", { api: state.api, language: this.language, "trek-id": this.currentTrekId }), (state.currentTreks || state.currentTrek) && (h("div", { class: "app-container" }, h("div", { class: this.isLargeView ? 'large-view-header-container' : 'header-container' }, this.showTrek ? (h("div", { onClick: () => this.handleBackButton(), class: "arrow-back-icon", innerHTML: arrowBackImage })) : (h("div", { class: "handle-filters-container" }, h("div", { onClick: () => this.handleFilters(), class: "handle-filters-button" }, "FILTRER"), state.treksWithinBounds && (h("div", { class: "current-treks-within-bounds-length" }, `${state.treksWithinBounds.length} randonnée${state.treksWithinBounds.length > 1 ? 's' : ''}`)))), !this.showTrek && this.showFilters && (h("div", { class: "options-container" }, h("div", { class: "filters-container" }, h("div", { onClick: () => this.handleFilters(), class: "close-filters-button" }, "X"), h("div", null, h("grw-filter", { filterName: "Pratique", filterType: "practices", filterNameProperty: "name" })), h("div", { class: "filter-margin-top" }, h("grw-filter", { filterName: "Difficult\u00E9", filterType: "difficulties", filterNameProperty: "label" })), h("div", { class: "filter-margin-top" }, h("grw-filter", { filterName: "Dur\u00E9e", filterType: "durations", filterNameProperty: "name" }))), h("div", { onClick: () => this.handleFilters(), class: "back-filters-container" }))), h("div", { class: "attribution-container" }, h("a", { target: "_blank", href: "https://geotrek.fr" }, "GEOTREK"))), h("div", { class: "content-container" }, h("div", { class: this.isLargeView ? 'large-view-app-treks-list-container' : 'app-treks-list-container', style: { display: this.showTrek ? 'none' : 'flex', position: this.showTrek ? 'absolute' : 'relative' } }, h("grw-treks-list", { "is-large-view": this.isLargeView, "color-primary": this.colorPrimary, "color-primary-tint": this.colorPrimaryTint })), this.showTrek && !state.currentTrek && (h("div", { class: this.isLargeView ? 'large-view-loader-container' : 'loader-container' }, h("span", { class: "loader" }))), state.currentTrek && (h("div", { class: this.isLargeView ? 'large-view-app-trek-detail-container' : 'app-trek-detail-container' }, h("grw-trek-detail", { "color-primary": this.colorPrimary, "color-primary-shade": this.colorPrimaryShade, "color-primary-tint": this.colorPrimaryTint }))), h("grw-map", { class: this.isLargeView ? 'large-view-app-map-container' : 'app-map-container', style: { visibility: (this.showTreksMap && !this.showTrek) || (this.showTrekMap && this.showTrek) ? 'visible' : 'hidden' }, "url-layer": this.urlLayer, center: this.center, zoom: this.zoom, attribution: this.attribution, "color-primary": this.colorPrimary, "color-primary-tint": this.colorPrimaryTint, "color-trek-line": this.colorTrekLine, "color-departure-icon": this.colorDepartureIcon, "color-arrival-icon": this.colorArrivalIcon, "color-sensitive-area": this.colorSensitiveArea, "color-poi-icon": this.colorPoiIcon })), h("div", { class: "map-visibility-button", style: { display: this.isLargeView ? 'none' : 'flex' } }, h("div", { onClick: () => this.handleShowMap() }, this.showTrek ? (this.showTrekMap ? 'Voir la fiche' : 'Voir la carte') : this.showTreksMap ? 'Voir la liste' : 'Voir la carte'))))));
93
120
  }
94
121
  get element() { return this; }
95
122
  static get watchers() { return {
@@ -109,7 +136,7 @@ const GrwApp$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
109
136
  "practices": [1],
110
137
  "urlLayer": [1, "url-layer"],
111
138
  "center": [1],
112
- "zoom": [8],
139
+ "zoom": [2],
113
140
  "attribution": [1],
114
141
  "colorPrimary": [1, "color-primary"],
115
142
  "colorPrimaryShade": [1, "color-primary-shade"],
@@ -29,18 +29,17 @@ const GrwFilter = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
29
29
  filtersTreks = [...filtersTreks.filter(trek => currentFiltersId.includes(trek[filter.trekProperty]))];
30
30
  }
31
31
  else if (filter.type === 'interval') {
32
- let minValue;
33
- let maxValue;
34
- for (const currentFilterId of currentFiltersId) {
35
- const currentFilter = state[filter.property].find(property => property.id === currentFilterId);
36
- if (isNaN(minValue) || currentFilter.minValue < minValue) {
37
- minValue = currentFilter.minValue;
38
- }
39
- if (isNaN(maxValue) || currentFilter.maxValue > maxValue) {
40
- maxValue = currentFilter.maxValue;
41
- }
42
- }
43
- filtersTreks = [...filtersTreks.filter(trek => trek[filter.trekProperty] >= minValue && trek[filter.trekProperty] <= maxValue)];
32
+ filtersTreks = [
33
+ ...filtersTreks.filter(trek => {
34
+ for (const currentFilterId of currentFiltersId) {
35
+ const currentFilter = state[filter.property].find(property => property.id === currentFilterId);
36
+ if (trek[filter.trekProperty] >= currentFilter.minValue && trek[filter.trekProperty] <= currentFilter.maxValue) {
37
+ return true;
38
+ }
39
+ }
40
+ return false;
41
+ }),
42
+ ];
44
43
  }
45
44
  }
46
45
  else {
@@ -14159,8 +14159,9 @@ const GrwMap = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
14159
14159
  this.colorArrivalIcon = '#85003b';
14160
14160
  this.colorSensitiveArea = ' #4974a5';
14161
14161
  this.colorPoiIcon = '#974c6e';
14162
+ this.handleTreksWithinBoundsBind = this.handleTreksWithinBounds.bind(this);
14162
14163
  }
14163
- componentDidLoad() {
14164
+ connectedCallback() {
14164
14165
  this.map = leafletSrc.map(this.element, {
14165
14166
  center: this.center.split(',').map(Number),
14166
14167
  zoom: this.zoom,
@@ -14173,7 +14174,7 @@ const GrwMap = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
14173
14174
  if (state.currentTrek) {
14174
14175
  this.addTrek();
14175
14176
  }
14176
- else if (state.currentTrek) {
14177
+ else if (state.currentTreks) {
14177
14178
  this.addTreks();
14178
14179
  }
14179
14180
  onChange('currentTreks', () => {
@@ -14202,29 +14203,35 @@ const GrwMap = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
14202
14203
  type: 'FeatureCollection',
14203
14204
  features: [],
14204
14205
  };
14205
- for (const trek of state.currentTreks) {
14206
- trekscurrentDepartureCoordinates.push(trek.departure_geom);
14207
- treksFeatureCollection.features.push({
14208
- type: 'Feature',
14209
- geometry: { type: 'Point', coordinates: trek.departure_geom },
14210
- properties: {
14211
- id: trek.id,
14212
- name: trek.name,
14213
- practice: (_a = state.practices.find(practice => practice.id === trek.practice)) === null || _a === void 0 ? void 0 : _a.pictogram,
14214
- imgSrc: trek.attachments && trek.attachments.length > 0 && trek.attachments[0].thumbnail,
14215
- },
14216
- });
14217
- }
14218
- if (trekscurrentDepartureCoordinates.length > 0) {
14219
- const bounds = leafletSrc.latLngBounds(trekscurrentDepartureCoordinates.map(coordinate => [coordinate[1], coordinate[0]]));
14220
- this.currentBounds = bounds;
14221
- this.map.fitBounds(this.currentBounds);
14206
+ if (state.currentTreks) {
14207
+ for (const trek of state.currentTreks) {
14208
+ trekscurrentDepartureCoordinates.push(trek.departure_geom);
14209
+ treksFeatureCollection.features.push({
14210
+ type: 'Feature',
14211
+ geometry: { type: 'Point', coordinates: trek.departure_geom },
14212
+ properties: {
14213
+ id: trek.id,
14214
+ name: trek.name,
14215
+ practice: (_a = state.practices.find(practice => practice.id === trek.practice)) === null || _a === void 0 ? void 0 : _a.pictogram,
14216
+ imgSrc: trek.attachments && trek.attachments.length > 0 && trek.attachments[0].thumbnail,
14217
+ },
14218
+ });
14219
+ }
14222
14220
  }
14223
14221
  if (!this.treksLayer) {
14222
+ if (trekscurrentDepartureCoordinates.length > 0 && !state.currentMapTreksBounds) {
14223
+ const bounds = leafletSrc.latLngBounds(trekscurrentDepartureCoordinates.map(coordinate => [coordinate[1], coordinate[0]]));
14224
+ this.map.fitBounds(bounds);
14225
+ }
14226
+ else {
14227
+ if (state.currentMapTreksBounds) {
14228
+ this.map.fitBounds(state.currentMapTreksBounds);
14229
+ }
14230
+ }
14224
14231
  this.treksLayer = leafletSrc.geoJSON(treksFeatureCollection, {
14225
14232
  pointToLayer: (geoJsonPoint, latlng) => leafletSrc.marker(latlng, {
14226
14233
  icon: leafletSrc.divIcon({
14227
- html: geoJsonPoint.properties.practice && `<img src=${geoJsonPoint.properties.practice} />`,
14234
+ html: geoJsonPoint.properties.practice ? `<img src=${geoJsonPoint.properties.practice} />` : `<img />`,
14228
14235
  className: 'trek-marker',
14229
14236
  iconSize: 48,
14230
14237
  }),
@@ -14251,17 +14258,30 @@ const GrwMap = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
14251
14258
  }).addTo(this.map);
14252
14259
  }
14253
14260
  else {
14261
+ if (trekscurrentDepartureCoordinates.length > 0) {
14262
+ const bounds = leafletSrc.latLngBounds(trekscurrentDepartureCoordinates.map(coordinate => [coordinate[1], coordinate[0]]));
14263
+ this.map.fitBounds(bounds);
14264
+ }
14265
+ else {
14266
+ this.map.fire('moveend');
14267
+ }
14254
14268
  this.treksLayer.clearLayers();
14255
14269
  this.treksLayer.addData(treksFeatureCollection);
14256
14270
  }
14257
14271
  !this.mapIsReady && (this.mapIsReady = !this.mapIsReady);
14272
+ this.map.on('moveend', this.handleTreksWithinBoundsBind);
14258
14273
  }
14259
14274
  removeTreks() {
14260
14275
  if (this.treksLayer) {
14276
+ state.currentMapTreksBounds = this.map.getBounds();
14261
14277
  this.map.removeLayer(this.treksLayer);
14262
14278
  this.treksLayer = null;
14279
+ this.map.off('moveend', this.handleTreksWithinBoundsBind);
14263
14280
  }
14264
14281
  }
14282
+ handleTreksWithinBounds() {
14283
+ state.treksWithinBounds = state.currentTreks.filter(trek => this.map.getBounds().contains(leafletSrc.latLng(trek.departure_geom[1], trek.departure_geom[0])));
14284
+ }
14265
14285
  addTrek() {
14266
14286
  const currentTrekFeature = {
14267
14287
  type: 'Feature',
@@ -14275,8 +14295,7 @@ const GrwMap = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
14275
14295
  interactive: false,
14276
14296
  }).addTo(this.map);
14277
14297
  const bounds = leafletSrc.latLngBounds(state.currentTrek.geometry.coordinates.map(coordinate => [coordinate[1], coordinate[0]]));
14278
- this.currentBounds = bounds;
14279
- this.map.fitBounds(this.currentBounds);
14298
+ this.map.fitBounds(bounds);
14280
14299
  const currentDepartureCoordinates = [state.currentTrek.geometry.coordinates.at(0)[0], state.currentTrek.geometry.coordinates.at(0)[1]];
14281
14300
  const currentArrivalCoordinates = [state.currentTrek.geometry.coordinates.at(-1)[0], state.currentTrek.geometry.coordinates.at(-1)[1]];
14282
14301
  const currentDepartureArrivalFeatureCollection = {
@@ -1,7 +1,7 @@
1
1
  import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
2
2
  import { s as state } from './store.js';
3
3
 
4
- const grwSensitiveAreaDetailCss = ":host{display:flex;flex-direction:column}:host a{color:var(--color-primary)}.sensitive-area-title{color:var(--color-primary);font-size:24px;padding:12px 0px}.sensitive-area-description{font-size:16px}.sensitive-area-period-container .sensitive-area-period-title,.sensitive-area-period-container .sensitive-area-practice-title,.sensitive-area-period-container .sensitive-area-contact-title,.sensitive-area-practice-container .sensitive-area-period-title,.sensitive-area-practice-container .sensitive-area-practice-title,.sensitive-area-practice-container .sensitive-area-contact-title,.sensitive-area-contact-container .sensitive-area-period-title,.sensitive-area-contact-container .sensitive-area-practice-title,.sensitive-area-contact-container .sensitive-area-contact-title{color:var(--color-primary);font-size:24px;padding:12px 0px}.sensitive-area-period-container .sensitive-area-period-values,.sensitive-area-period-container .sensitive-area-practice-values,.sensitive-area-practice-container .sensitive-area-period-values,.sensitive-area-practice-container .sensitive-area-practice-values,.sensitive-area-contact-container .sensitive-area-period-values,.sensitive-area-contact-container .sensitive-area-practice-values{display:flex}";
4
+ const grwSensitiveAreaDetailCss = ":host{display:flex;flex-direction:column}:host a{color:var(--color-primary)}.sensitive-area-title{color:var(--color-primary);font-size:24px;padding:12px 0px;font-weight:bold}.sensitive-area-description{font-size:16px}.sensitive-area-period-container .sensitive-area-period-title,.sensitive-area-period-container .sensitive-area-practice-title,.sensitive-area-period-container .sensitive-area-contact-title,.sensitive-area-practice-container .sensitive-area-period-title,.sensitive-area-practice-container .sensitive-area-practice-title,.sensitive-area-practice-container .sensitive-area-contact-title,.sensitive-area-contact-container .sensitive-area-period-title,.sensitive-area-contact-container .sensitive-area-practice-title,.sensitive-area-contact-container .sensitive-area-contact-title{color:var(--color-primary);font-size:24px;padding:12px 0px}.sensitive-area-period-container .sensitive-area-period-values,.sensitive-area-period-container .sensitive-area-practice-values,.sensitive-area-practice-container .sensitive-area-period-values,.sensitive-area-practice-container .sensitive-area-practice-values,.sensitive-area-contact-container .sensitive-area-period-values,.sensitive-area-contact-container .sensitive-area-practice-values{display:flex}";
5
5
 
6
6
  const GrwSensitiveAreaDetail = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
7
7
  constructor() {
@@ -14,7 +14,7 @@ const GrwTrekCard = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
14
14
  this.colorPrimaryTint = '#974c6e';
15
15
  this.isLargeView = false;
16
16
  }
17
- componentWillLoad() {
17
+ connectedCallback() {
18
18
  this.currentTrek = this.trek ? this.trek : state.currentTrek;
19
19
  if (this.currentTrek) {
20
20
  this.difficulty = state.difficulties.find(difficulty => difficulty.id === this.currentTrek.difficulty);