@geotrekce/geotrek-rando-widget 0.0.3 → 0.0.6

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 (80) hide show
  1. package/dist/cjs/geotrek-rando-widget.cjs.js +2 -2
  2. package/dist/cjs/grw-app.cjs.entry.js +111 -0
  3. package/dist/cjs/{grw-app_10.cjs.entry.js → grw-filter_6.cjs.entry.js} +284 -446
  4. package/dist/cjs/grw-information-desk-detail_3.cjs.entry.js +52 -0
  5. package/dist/cjs/grw-trek-card.cjs.entry.js +47 -0
  6. package/dist/cjs/{index-c6f73e30.js → index-c2c4531d.js} +46 -1
  7. package/dist/cjs/length-d315d156.js +34 -0
  8. package/dist/cjs/loader.cjs.js +2 -2
  9. package/dist/cjs/store-fd04a216.js +211 -0
  10. package/dist/collection/collection-manifest.json +1 -0
  11. package/dist/collection/components/grw-app/grw-app.css +69 -5
  12. package/dist/collection/components/grw-app/grw-app.js +76 -28
  13. package/dist/collection/components/grw-filter/grw-filter.css +29 -0
  14. package/dist/collection/components/grw-filter/grw-filter.js +132 -0
  15. package/dist/collection/components/grw-information-desk-detail/grw-information-desk-detail.css +5 -4
  16. package/dist/collection/components/grw-information-desk-detail/grw-information-desk-detail.js +1 -1
  17. package/dist/collection/components/grw-map/grw-map.css +19 -1
  18. package/dist/collection/components/grw-map/grw-map.js +101 -40
  19. package/dist/collection/components/grw-poi-detail/grw-poi-detail.css +5 -4
  20. package/dist/collection/components/grw-poi-detail/grw-poi-detail.js +1 -1
  21. package/dist/collection/components/grw-sensitive-area-detail/grw-sensitive-area-detail.css +27 -3
  22. package/dist/collection/components/grw-sensitive-area-detail/grw-sensitive-area-detail.js +17 -3
  23. package/dist/collection/components/grw-trek-card/grw-trek-card.css +66 -32
  24. package/dist/collection/components/grw-trek-card/grw-trek-card.js +34 -10
  25. package/dist/collection/components/grw-trek-detail/grw-trek-detail.css +134 -4
  26. package/dist/collection/components/grw-trek-detail/grw-trek-detail.js +95 -6
  27. package/dist/collection/components/grw-treks-list/grw-treks-list.css +16 -3
  28. package/dist/collection/components/grw-treks-list/grw-treks-list.js +33 -6
  29. package/dist/collection/store/grw-trek-provider.js +32 -10
  30. package/dist/collection/store/grw-treks-provider.js +14 -4
  31. package/dist/collection/store/store.js +10 -1
  32. package/dist/collection/stories/App.js +8 -10
  33. package/dist/collection/stories/App.stories.js +4 -3
  34. package/dist/collection/stories/TrekMap.stories.js +3 -2
  35. package/dist/collection/stories/TreksList.js +8 -8
  36. package/dist/collection/stories/TreksMap.stories.js +3 -2
  37. package/dist/components/grw-app.js +66 -9
  38. package/dist/components/grw-filter.d.ts +11 -0
  39. package/dist/components/grw-filter.js +6 -0
  40. package/dist/components/grw-filter2.js +95 -0
  41. package/dist/components/grw-information-desk-detail2.js +2 -2
  42. package/dist/components/grw-map2.js +102 -41
  43. package/dist/components/grw-poi-detail2.js +2 -2
  44. package/dist/components/grw-sensitive-area-detail2.js +7 -2
  45. package/dist/components/grw-trek-card2.js +10 -5
  46. package/dist/components/grw-trek-detail2.js +25 -4
  47. package/dist/components/grw-trek-provider2.js +32 -10
  48. package/dist/components/grw-treks-list2.js +15 -7
  49. package/dist/components/grw-treks-provider2.js +14 -4
  50. package/dist/components/store.js +10 -1
  51. package/dist/esm/geotrek-rando-widget.js +2 -2
  52. package/dist/esm/grw-app.entry.js +107 -0
  53. package/dist/esm/{grw-app_10.entry.js → grw-filter_6.entry.js} +246 -404
  54. package/dist/esm/grw-information-desk-detail_3.entry.js +46 -0
  55. package/dist/esm/grw-trek-card.entry.js +43 -0
  56. package/dist/esm/{index-7aa9e822.js → index-192d910f.js} +47 -2
  57. package/dist/esm/length-d82189db.js +27 -0
  58. package/dist/esm/loader.js +2 -2
  59. package/dist/esm/store-b2c76c0c.js +208 -0
  60. package/dist/geotrek-rando-widget/geotrek-rando-widget.esm.js +1 -1
  61. package/dist/geotrek-rando-widget/p-1b2ba86d.entry.js +1 -0
  62. package/dist/geotrek-rando-widget/p-5f17d340.entry.js +1 -0
  63. package/dist/geotrek-rando-widget/p-6716c635.entry.js +1 -0
  64. package/dist/geotrek-rando-widget/p-6dce5e6c.js +2 -0
  65. package/dist/geotrek-rando-widget/p-7715153d.entry.js +1 -0
  66. package/dist/geotrek-rando-widget/p-e6710c64.js +1 -0
  67. package/dist/geotrek-rando-widget/p-f3f7d6be.js +1 -0
  68. package/dist/types/components/grw-app/grw-app.d.ts +9 -2
  69. package/dist/types/components/grw-filter/grw-filter.d.ts +9 -0
  70. package/dist/types/components/grw-map/grw-map.d.ts +3 -1
  71. package/dist/types/components/grw-trek-card/grw-trek-card.d.ts +6 -4
  72. package/dist/types/components/grw-trek-detail/grw-trek-detail.d.ts +9 -4
  73. package/dist/types/components/grw-treks-list/grw-treks-list.d.ts +1 -0
  74. package/dist/types/components.d.ts +23 -2
  75. package/dist/types/store/store.d.ts +22 -3
  76. package/dist/types/types/types.d.ts +74 -1
  77. package/package.json +5 -4
  78. package/readme.md +4 -5
  79. package/dist/geotrek-rando-widget/p-332ba9ab.js +0 -2
  80. package/dist/geotrek-rando-widget/p-73bc92fe.entry.js +0 -1
@@ -2,7 +2,7 @@ import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal
2
2
  import { o as onChange, s as state } from './store.js';
3
3
  import { d as defineCustomElement$1 } from './grw-trek-card2.js';
4
4
 
5
- const grwTreksListCss = ":host{font-family:\"Roboto\";display:flex;flex-wrap:wrap;justify-content:space-around;height:100%;max-height:100vh;overflow-y:auto}grw-trek-card{margin:6px}";
5
+ const grwTreksListCss = ":host{font-family:\"Roboto\";width:100%;height:100%;max-height:100vh;overflow-y:auto}.current-treks-length{width:100%;text-align:center;padding:32px 0px;color:var(--color-primary);font-size:24px;font-weight:bold}.current-treks-container{display:flex;flex-wrap:wrap;justify-content:space-around}grw-trek-card{margin:6px}";
6
6
 
7
7
  const GrwTreksList = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
8
8
  constructor() {
@@ -12,19 +12,26 @@ const GrwTreksList = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
12
12
  this.treksToDisplay = [];
13
13
  this.colorPrimary = '#6b0030';
14
14
  this.colorPrimaryTint = '#974c6e';
15
+ this.isLargeView = false;
15
16
  this.handleInfiniteScrollBind = this.handleInfiniteScroll.bind(this);
16
17
  this.step = 10;
17
18
  }
18
19
  componentWillLoad() {
19
- this.element.addEventListener('scroll', this.handleInfiniteScrollBind);
20
- onChange('treks', () => {
21
- this.treksToDisplay = state.treks.slice(0, this.step);
20
+ onChange('currentTreks', () => {
21
+ this.element.addEventListener('scroll', this.handleInfiniteScrollBind);
22
+ this.element.scroll({ top: 0 });
23
+ this.treksToDisplay = [...state.currentTreks.slice(0, this.step)];
24
+ });
25
+ onChange('treksWithinBounds', () => {
26
+ this.element.addEventListener('scroll', this.handleInfiniteScrollBind);
27
+ this.element.scroll({ top: 0 });
28
+ this.treksToDisplay = [...state.treksWithinBounds.slice(0, this.step)];
22
29
  });
23
30
  }
24
31
  handleInfiniteScroll(event) {
25
32
  if (event.composedPath()[0].scrollTop + event.composedPath()[0].scrollHeight / 2 >= event.composedPath()[0].scrollHeight) {
26
- if (this.treksToDisplay.length < state.treks.length) {
27
- this.treksToDisplay = state.treks.slice(0, this.treksToDisplay.length + this.step >= state.treks.length ? state.treks.length : this.treksToDisplay.length + this.step);
33
+ if (this.treksToDisplay.length < state.treksWithinBounds.length) {
34
+ this.treksToDisplay = state.treksWithinBounds.slice(0, this.treksToDisplay.length + this.step >= state.treksWithinBounds.length ? state.treksWithinBounds.length : this.treksToDisplay.length + this.step);
28
35
  }
29
36
  else {
30
37
  this.element.removeEventListener('scroll', this.handleInfiniteScrollBind);
@@ -32,13 +39,14 @@ const GrwTreksList = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
32
39
  }
33
40
  }
34
41
  render() {
35
- return (h(Host, { style: { '--color-primary': this.colorPrimary, '--color-primary-tint': this.colorPrimaryTint } }, this.treksToDisplay.map(trek => (h("grw-trek-card", { trek: trek, "color-primary": this.colorPrimary, "color-primary-tint": this.colorPrimaryTint })))));
42
+ return (h(Host, { style: { '--color-primary': this.colorPrimary, '--color-primary-tint': this.colorPrimaryTint } }, h("div", { class: "current-treks-length" }, `${state.treksWithinBounds.length} résultat${state.treksWithinBounds.length > 1 ? 's' : ''}`), 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 }))))));
36
43
  }
37
44
  get element() { return this; }
38
45
  static get style() { return grwTreksListCss; }
39
46
  }, [1, "grw-treks-list", {
40
47
  "colorPrimary": [1, "color-primary"],
41
48
  "colorPrimaryTint": [1, "color-primary-tint"],
49
+ "isLargeView": [4, "is-large-view"],
42
50
  "treksToDisplay": [32]
43
51
  }]);
44
52
  function defineCustomElement() {
@@ -10,7 +10,7 @@ const GrwTreksProvider = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
10
10
  }
11
11
  componentWillLoad() {
12
12
  state.api = this.api;
13
- let treksRequest = `${this.api}trek/?language=${this.language}`;
13
+ let treksRequest = `${this.api}trek/?language=${this.language}&published=true`;
14
14
  this.inBbox && (treksRequest += `&in_bbox=${this.inBbox}`);
15
15
  this.cities && (treksRequest += `&cities=${this.cities}`);
16
16
  this.districts && (treksRequest += `&districts=${this.districts}`);
@@ -19,19 +19,29 @@ const GrwTreksProvider = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
19
19
  this.portals && (treksRequest += `&portals=${this.portals}`);
20
20
  this.routes && (treksRequest += `&routes=${this.routes}`);
21
21
  this.practices && (treksRequest += `&practices=${this.practices}`);
22
- treksRequest += `&fields=id,name,attachments,description_teaser,difficulty,duration,ascent,length_2d,practice,route,departure_geom&page_size=999`;
22
+ treksRequest += `&fields=id,name,attachments,description_teaser,difficulty,duration,ascent,length_2d,practice,themes,route,departure,departure_geom&page_size=999`;
23
23
  return Promise.all([
24
24
  fetch(`${this.api}trek_difficulty/?language=${this.language}&fields=id,label,pictogram`),
25
25
  fetch(`${this.api}trek_route/?language=${this.language}&fields=id,route,pictogram`),
26
26
  fetch(`${this.api}trek_practice/?language=${this.language}&fields=id,name,pictogram`),
27
+ fetch(`${this.api}theme/?language=${this.language}&fields=id,label,pictogram`),
27
28
  fetch(treksRequest),
28
29
  ])
29
30
  .then(responses => Promise.all(responses.map(response => response.json())))
30
- .then(([difficulties, routes, practices, treks]) => {
31
+ .then(([difficulties, routes, practices, themes, treks]) => {
31
32
  state.difficulties = difficulties.results;
32
33
  state.routes = routes.results;
33
- state.practices = practices.results;
34
+ state.practices = practices.results.map(practice => (Object.assign(Object.assign({}, practice), { selected: false })));
35
+ state.themes = themes.results;
36
+ state.durations = [
37
+ { id: 1, name: '0 - 1h', minValue: 0, maxValue: 1, selected: false },
38
+ { id: 2, name: '1 - 2h', minValue: 1, maxValue: 2, selected: false },
39
+ { id: 3, name: '2 - 5h', minValue: 2, maxValue: 5, selected: false },
40
+ { id: 4, name: '5 - 10h', minValue: 5, maxValue: 10, selected: false },
41
+ ];
34
42
  state.treks = treks.results;
43
+ state.currentTreks = treks.results;
44
+ state.treksWithinBounds = treks.results;
35
45
  });
36
46
  }
37
47
  render() {
@@ -187,12 +187,21 @@ const createStore = (defaultState, shouldUpdate) => {
187
187
  const { state, onChange } = createStore({
188
188
  api: '',
189
189
  treks: [],
190
+ currentTreks: [],
191
+ treksWithinBounds: [],
192
+ currentMapTreksBounds: null,
190
193
  difficulties: [],
191
194
  routes: [],
192
195
  practices: [],
196
+ themes: [],
197
+ durations: [],
193
198
  currentSensitiveAreas: null,
194
- currentPois: null,
199
+ labels: null,
200
+ sources: null,
201
+ accessibilities: null,
202
+ accessibilitiesLevel: null,
195
203
  currentTrek: null,
204
+ currentPois: null,
196
205
  currentInformationDesks: null,
197
206
  });
198
207
 
@@ -1,4 +1,4 @@
1
- import { p as promiseResolve, b as bootstrapLazy } from './index-7aa9e822.js';
1
+ import { p as promiseResolve, b as bootstrapLazy } from './index-192d910f.js';
2
2
 
3
3
  /*
4
4
  Stencil Client Patch Browser v2.16.1 | MIT Licensed | https://stenciljs.com
@@ -13,5 +13,5 @@ const patchBrowser = () => {
13
13
  };
14
14
 
15
15
  patchBrowser().then(options => {
16
- return bootstrapLazy([["grw-app_10",[[1,"grw-app",{"api":[1],"language":[1],"inBbox":[1,"in-bbox"],"cities":[1],"districts":[1],"structures":[1],"themes":[1],"portals":[1],"routes":[1],"practices":[1],"appName":[1,"app-name"],"urlLayer":[1,"url-layer"],"center":[1],"zoom":[8],"attribution":[1],"colorPrimary":[1,"color-primary"],"colorPrimaryShade":[1,"color-primary-shade"],"colorPrimaryTint":[1,"color-primary-tint"],"colorTrekLine":[1,"color-trek-line"],"colorDepartureIcon":[1,"color-departure-icon"],"colorArrivalIcon":[1,"color-arrival-icon"],"colorSensitiveArea":[1,"color-sensitive-area"],"colorPoiIcon":[1,"color-poi-icon"],"showTrek":[32],"showMap":[32],"isLargeView":[32],"currentTrekId":[32]},[[0,"trekCardPress","onTrekCardPress"],[9,"resize","onWindowResize"]]],[1,"grw-trek-detail",{"trek":[16],"colorPrimary":[1,"color-primary"],"colorPrimaryShade":[1,"color-primary-shade"],"colorPrimaryTint":[1,"color-primary-tint"],"currentTrek":[32],"difficulty":[32],"route":[32],"practice":[32]}],[1,"grw-treks-list",{"colorPrimary":[1,"color-primary"],"colorPrimaryTint":[1,"color-primary-tint"],"treksToDisplay":[32]}],[0,"grw-map",{"urlLayer":[1,"url-layer"],"attribution":[1],"center":[1],"zoom":[2],"colorPrimary":[1,"color-primary"],"colorPrimaryTint":[1,"color-primary-tint"],"colorTrekLine":[1,"color-trek-line"],"colorDepartureIcon":[1,"color-departure-icon"],"colorArrivalIcon":[1,"color-arrival-icon"],"colorSensitiveArea":[1,"color-sensitive-area"],"colorPoiIcon":[1,"color-poi-icon"],"mapIsReady":[32]}],[1,"grw-trek-provider",{"language":[1],"api":[1],"trekId":[1,"trek-id"]}],[1,"grw-treks-provider",{"language":[1],"api":[1],"inBbox":[1,"in-bbox"],"cities":[1],"districts":[1],"structures":[1],"themes":[1],"portals":[1],"routes":[1],"practices":[1]}],[1,"grw-information-desk-detail",{"informationDesk":[16]}],[1,"grw-poi-detail",{"poi":[16]}],[1,"grw-sensitive-area-detail",{"sensitiveArea":[16]}],[1,"grw-trek-card",{"trek":[16],"colorPrimary":[1,"color-primary"],"colorPrimaryTint":[1,"color-primary-tint"],"currentTrek":[32],"difficulty":[32],"route":[32],"practice":[32]}]]]], options);
16
+ return bootstrapLazy([["grw-trek-card",[[1,"grw-trek-card",{"trek":[16],"colorPrimary":[1,"color-primary"],"colorPrimaryTint":[1,"color-primary-tint"],"isLargeView":[4,"is-large-view"],"currentTrek":[32],"difficulty":[32],"route":[32],"practice":[32],"themes":[32]}]]],["grw-information-desk-detail_3",[[1,"grw-information-desk-detail",{"informationDesk":[16]}],[1,"grw-poi-detail",{"poi":[16]}],[1,"grw-sensitive-area-detail",{"sensitiveArea":[16]}]]],["grw-filter_6",[[1,"grw-trek-detail",{"trek":[16],"colorPrimary":[1,"color-primary"],"colorPrimaryShade":[1,"color-primary-shade"],"colorPrimaryTint":[1,"color-primary-tint"],"difficulty":[32],"route":[32],"practice":[32],"themes":[32],"labels":[32],"sources":[32],"accessibilities":[32],"accessibilityLevel":[32],"currentTrek":[32]}],[1,"grw-treks-list",{"colorPrimary":[1,"color-primary"],"colorPrimaryTint":[1,"color-primary-tint"],"isLargeView":[4,"is-large-view"],"treksToDisplay":[32]}],[1,"grw-filter",{"filterType":[1,"filter-type"],"filterName":[1,"filter-name"],"filterNameProperty":[1,"filter-name-property"]}],[0,"grw-map",{"urlLayer":[1,"url-layer"],"attribution":[1],"center":[1],"zoom":[2],"colorPrimary":[1,"color-primary"],"colorPrimaryTint":[1,"color-primary-tint"],"colorTrekLine":[1,"color-trek-line"],"colorDepartureIcon":[1,"color-departure-icon"],"colorArrivalIcon":[1,"color-arrival-icon"],"colorSensitiveArea":[1,"color-sensitive-area"],"colorPoiIcon":[1,"color-poi-icon"],"mapIsReady":[32]}],[1,"grw-trek-provider",{"language":[1],"api":[1],"trekId":[1,"trek-id"]}],[1,"grw-treks-provider",{"language":[1],"api":[1],"inBbox":[1,"in-bbox"],"cities":[1],"districts":[1],"structures":[1],"themes":[1],"portals":[1],"routes":[1],"practices":[1]}]]],["grw-app",[[1,"grw-app",{"api":[1],"language":[1],"inBbox":[1,"in-bbox"],"cities":[1],"districts":[1],"structures":[1],"themes":[1],"portals":[1],"routes":[1],"practices":[1],"urlLayer":[1,"url-layer"],"center":[1],"zoom":[8],"attribution":[1],"colorPrimary":[1,"color-primary"],"colorPrimaryShade":[1,"color-primary-shade"],"colorPrimaryTint":[1,"color-primary-tint"],"colorTrekLine":[1,"color-trek-line"],"colorDepartureIcon":[1,"color-departure-icon"],"colorArrivalIcon":[1,"color-arrival-icon"],"colorSensitiveArea":[1,"color-sensitive-area"],"colorPoiIcon":[1,"color-poi-icon"],"showTrek":[32],"showTreksMap":[32],"showTrekMap":[32],"showFilters":[32],"isLargeView":[32],"currentTrekId":[32]},[[0,"trekCardPress","onTrekCardPress"],[9,"resize","onWindowResize"]]]]]], options);
17
17
  });
@@ -0,0 +1,107 @@
1
+ import { r as registerInstance, h, H as Host, g as getElement } from './index-192d910f.js';
2
+ import { s as state } from './store-b2c76c0c.js';
3
+
4
+ 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>`;
5
+
6
+ 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%}";
7
+
8
+ const GrwApp = class {
9
+ constructor(hostRef) {
10
+ registerInstance(this, hostRef);
11
+ this.showTrek = false;
12
+ this.showTreksMap = false;
13
+ this.showTrekMap = false;
14
+ this.showFilters = false;
15
+ this.isLargeView = false;
16
+ this.language = 'fr';
17
+ this.colorPrimary = '#6b0030';
18
+ this.colorPrimaryShade = '#4a0021';
19
+ this.colorPrimaryTint = '#974c6e';
20
+ this.colorTrekLine = '#6b0030';
21
+ this.colorDepartureIcon = '#006b3b';
22
+ this.colorArrivalIcon = '#85003b';
23
+ this.colorSensitiveArea = '#4974a5';
24
+ this.colorPoiIcon = '#974c6e';
25
+ this.handlePopStateBind = this.handlePopState.bind(this);
26
+ this.largeViewSize = 1024;
27
+ }
28
+ onTrekCardPress(event) {
29
+ this.currentTrekId = event.detail;
30
+ this.showTrek = !this.showTrek;
31
+ const url = new URL(window.location.toString());
32
+ url.searchParams.set('trek', this.currentTrekId.toString());
33
+ window.history.pushState({}, '', url);
34
+ }
35
+ onWindowResize() {
36
+ this.handleView();
37
+ }
38
+ watchPropHandler() {
39
+ window.dispatchEvent(new window.Event('resize'));
40
+ }
41
+ componentDidLoad() {
42
+ this.handleView();
43
+ window.addEventListener('popstate', this.handlePopStateBind, false);
44
+ const url = new URL(window.location.toString());
45
+ const trekParam = url.searchParams.get('trek');
46
+ if (trekParam) {
47
+ window.history.replaceState({ isInitialHistoryWithTrek: true }, '', url);
48
+ this.currentTrekId = Number(trekParam);
49
+ this.showTrek = !this.showTrek;
50
+ }
51
+ }
52
+ onTrekDetailsClose() {
53
+ this.currentTrekId = null;
54
+ this.showTrek = !this.showTrek;
55
+ }
56
+ handleView() {
57
+ this.isLargeView = this.element.getBoundingClientRect().width >= this.largeViewSize;
58
+ this.showTreksMap = this.isLargeView;
59
+ this.showTrekMap = this.isLargeView;
60
+ }
61
+ handleFilters() {
62
+ this.showFilters = !this.showFilters;
63
+ }
64
+ handleBackButton() {
65
+ if (window.history.state.isInitialHistoryWithTrek) {
66
+ this.onTrekDetailsClose();
67
+ const url = new URL(window.location.toString());
68
+ url.searchParams.delete('trek');
69
+ window.history.pushState({}, '', url);
70
+ }
71
+ else {
72
+ window.history.back();
73
+ }
74
+ }
75
+ handlePopState() {
76
+ const url = new URL(window.location.toString());
77
+ const trekParam = url.searchParams.get('trek');
78
+ if (trekParam) {
79
+ this.currentTrekId = Number(trekParam);
80
+ this.showTrek = !this.showTrek;
81
+ }
82
+ else {
83
+ this.onTrekDetailsClose();
84
+ }
85
+ }
86
+ handleShowMap() {
87
+ if (this.currentTrekId) {
88
+ this.showTrekMap = !this.showTrekMap;
89
+ }
90
+ else {
91
+ this.showTreksMap = !this.showTreksMap;
92
+ }
93
+ }
94
+ disconnectedCallback() {
95
+ window.removeEventListener('popstate', this.handlePopStateBind);
96
+ }
97
+ render() {
98
+ 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: () => this.handleBackButton(), 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')))));
99
+ }
100
+ get element() { return getElement(this); }
101
+ static get watchers() { return {
102
+ "isLargeView": ["watchPropHandler"]
103
+ }; }
104
+ };
105
+ GrwApp.style = grwAppCss;
106
+
107
+ export { GrwApp as grw_app };