@geotrekce/geotrek-rando-widget 0.0.3 → 0.0.4

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 (51) hide show
  1. package/dist/cjs/geotrek-rando-widget.cjs.js +2 -2
  2. package/dist/cjs/{grw-app_10.cjs.entry.js → grw-app_11.cjs.entry.js} +172 -58
  3. package/dist/cjs/{index-c6f73e30.js → index-c2c4531d.js} +46 -1
  4. package/dist/cjs/loader.cjs.js +2 -2
  5. package/dist/collection/collection-manifest.json +1 -0
  6. package/dist/collection/components/grw-app/grw-app.css +69 -5
  7. package/dist/collection/components/grw-app/grw-app.js +24 -5
  8. package/dist/collection/components/grw-filter/grw-filter.css +29 -0
  9. package/dist/collection/components/grw-filter/grw-filter.js +132 -0
  10. package/dist/collection/components/grw-map/grw-map.js +37 -31
  11. package/dist/collection/components/grw-trek-card/grw-trek-card.css +66 -32
  12. package/dist/collection/components/grw-trek-card/grw-trek-card.js +34 -10
  13. package/dist/collection/components/grw-trek-detail/grw-trek-detail.js +1 -1
  14. package/dist/collection/components/grw-treks-list/grw-treks-list.css +16 -3
  15. package/dist/collection/components/grw-treks-list/grw-treks-list.js +27 -5
  16. package/dist/collection/store/grw-trek-provider.js +24 -10
  17. package/dist/collection/store/grw-treks-provider.js +12 -3
  18. package/dist/collection/store/store.js +3 -0
  19. package/dist/collection/stories/App.js +8 -10
  20. package/dist/collection/stories/App.stories.js +4 -3
  21. package/dist/collection/stories/TrekMap.stories.js +3 -2
  22. package/dist/collection/stories/TreksList.js +8 -8
  23. package/dist/collection/stories/TreksMap.stories.js +3 -2
  24. package/dist/components/grw-app.js +15 -4
  25. package/dist/components/grw-filter.d.ts +11 -0
  26. package/dist/components/grw-filter.js +6 -0
  27. package/dist/components/grw-filter2.js +95 -0
  28. package/dist/components/grw-map2.js +37 -31
  29. package/dist/components/grw-trek-card2.js +10 -5
  30. package/dist/components/grw-trek-provider2.js +24 -10
  31. package/dist/components/grw-treks-list2.js +9 -6
  32. package/dist/components/grw-treks-provider2.js +12 -3
  33. package/dist/components/store.js +3 -0
  34. package/dist/esm/geotrek-rando-widget.js +2 -2
  35. package/dist/esm/{grw-app_10.entry.js → grw-app_11.entry.js} +172 -59
  36. package/dist/esm/{index-7aa9e822.js → index-fe16e7b6.js} +46 -1
  37. package/dist/esm/loader.js +2 -2
  38. package/dist/geotrek-rando-widget/geotrek-rando-widget.esm.js +1 -1
  39. package/dist/geotrek-rando-widget/p-8c206aec.js +2 -0
  40. package/dist/geotrek-rando-widget/p-ed8706fb.entry.js +1 -0
  41. package/dist/types/components/grw-app/grw-app.d.ts +2 -0
  42. package/dist/types/components/grw-filter/grw-filter.d.ts +9 -0
  43. package/dist/types/components/grw-trek-card/grw-trek-card.d.ts +6 -4
  44. package/dist/types/components/grw-treks-list/grw-treks-list.d.ts +1 -0
  45. package/dist/types/components.d.ts +23 -0
  46. package/dist/types/store/store.d.ts +7 -1
  47. package/dist/types/types/types.d.ts +23 -0
  48. package/package.json +1 -1
  49. package/readme.md +4 -5
  50. package/dist/geotrek-rando-widget/p-332ba9ab.js +0 -2
  51. package/dist/geotrek-rando-widget/p-73bc92fe.entry.js +0 -1
@@ -84,7 +84,7 @@ export class GrwTrekDetail {
84
84
  "mutable": false,
85
85
  "complexType": {
86
86
  "original": "Trek",
87
- "resolved": "{ id: number; name: string; attachments: Attachments; description?: string; description_teaser: string; difficulty: number; route: number; practice: number; duration: number; length_2d: number; ascent: number; geometry?: LineString; departure_geom?: Position; gpx?: string; kml?: string; pdf?: string; parking_location?: Position; }",
87
+ "resolved": "{ id: number; name: string; attachments: Attachments; description?: string; description_teaser: string; difficulty: number; route: number; practice: number; themes: number[]; duration: number; length_2d: number; ascent: number; departure: string; geometry?: LineString; departure_geom?: Position; gpx?: string; kml?: string; pdf?: string; parking_location?: Position; }",
88
88
  "references": {
89
89
  "Trek": {
90
90
  "location": "import",
@@ -1,13 +1,26 @@
1
1
  :host {
2
2
  font-family: "Roboto";
3
- display: flex;
4
- flex-wrap: wrap;
5
- justify-content: space-around;
3
+ width: 100%;
6
4
  height: 100%;
7
5
  max-height: 100vh;
8
6
  overflow-y: auto;
9
7
  }
10
8
 
9
+ .current-treks-length {
10
+ width: 100%;
11
+ text-align: center;
12
+ padding: 32px 0px;
13
+ color: var(--color-primary);
14
+ font-size: 24px;
15
+ font-weight: bold;
16
+ }
17
+
18
+ .current-treks-container {
19
+ display: flex;
20
+ flex-wrap: wrap;
21
+ justify-content: space-around;
22
+ }
23
+
11
24
  grw-trek-card {
12
25
  margin: 6px;
13
26
  }
@@ -5,19 +5,21 @@ export class GrwTreksList {
5
5
  this.treksToDisplay = [];
6
6
  this.colorPrimary = '#6b0030';
7
7
  this.colorPrimaryTint = '#974c6e';
8
+ this.isLargeView = false;
8
9
  this.handleInfiniteScrollBind = this.handleInfiniteScroll.bind(this);
9
10
  this.step = 10;
10
11
  }
11
12
  componentWillLoad() {
12
- this.element.addEventListener('scroll', this.handleInfiniteScrollBind);
13
- onChange('treks', () => {
14
- this.treksToDisplay = state.treks.slice(0, this.step);
13
+ onChange('currentTreks', () => {
14
+ this.element.addEventListener('scroll', this.handleInfiniteScrollBind);
15
+ this.element.scroll({ top: 0 });
16
+ this.treksToDisplay = [...state.currentTreks.slice(0, this.step)];
15
17
  });
16
18
  }
17
19
  handleInfiniteScroll(event) {
18
20
  if (event.composedPath()[0].scrollTop + event.composedPath()[0].scrollHeight / 2 >= event.composedPath()[0].scrollHeight) {
19
21
  if (this.treksToDisplay.length < state.treks.length) {
20
- this.treksToDisplay = state.treks.slice(0, this.treksToDisplay.length + this.step >= state.treks.length ? state.treks.length : this.treksToDisplay.length + this.step);
22
+ this.treksToDisplay = state.currentTreks.slice(0, this.treksToDisplay.length + this.step >= state.currentTreks.length ? state.currentTreks.length : this.treksToDisplay.length + this.step);
21
23
  }
22
24
  else {
23
25
  this.element.removeEventListener('scroll', this.handleInfiniteScrollBind);
@@ -25,7 +27,9 @@ export class GrwTreksList {
25
27
  }
26
28
  }
27
29
  render() {
28
- 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 })))));
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 }))))));
29
33
  }
30
34
  static get is() { return "grw-treks-list"; }
31
35
  static get encapsulation() { return "shadow"; }
@@ -71,6 +75,24 @@ export class GrwTreksList {
71
75
  "attribute": "color-primary-tint",
72
76
  "reflect": false,
73
77
  "defaultValue": "'#974c6e'"
78
+ },
79
+ "isLargeView": {
80
+ "type": "boolean",
81
+ "mutable": false,
82
+ "complexType": {
83
+ "original": "boolean",
84
+ "resolved": "boolean",
85
+ "references": {}
86
+ },
87
+ "required": false,
88
+ "optional": false,
89
+ "docs": {
90
+ "tags": [],
91
+ "text": ""
92
+ },
93
+ "attribute": "is-large-view",
94
+ "reflect": false,
95
+ "defaultValue": "false"
74
96
  }
75
97
  }; }
76
98
  static get states() { return {
@@ -6,21 +6,35 @@ export class GrwTrekProvider {
6
6
  }
7
7
  componentWillLoad() {
8
8
  state.api = this.api;
9
+ 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'));
9
14
  return Promise.all([
10
- fetch(`${this.api}trek_difficulty/?language=${this.language}&fields=id,label,pictogram`),
11
- fetch(`${this.api}trek_route/?language=${this.language}&fields=id,route,pictogram`),
12
- fetch(`${this.api}trek_practice/?language=${this.language}&fields=id,name,pictogram`),
13
- fetch(`${this.api}sensitivearea/?language=${this.language}&trek=${this.trekId}&fields=id,geometry,name,description`).catch(() => new Response('[]')),
15
+ ...requests,
16
+ fetch(`${this.api}sensitivearea/?language=${this.language}&trek=${this.trekId}&fields=id,geometry,name,description`).catch(() => new Response('null')),
14
17
  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`),
15
18
  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`),
16
- fetch(`${this.api}trek/${this.trekId}/?language=${this.language}&published=true&fields=id,name,attachments,description,description_teaser,difficulty,duration,ascent,length_2d,practice,route,geometry,gpx,kml,pdf,parking_location`),
19
+ 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`),
17
20
  ])
18
21
  .then(responses => Promise.all(responses.map(response => response.json())))
19
- .then(([difficulties, routes, practices, sensitiveAreas, pois, informationDesks, trek]) => {
20
- state.difficulties = difficulties.results;
21
- state.routes = routes.results;
22
- state.practices = practices.results;
23
- state.currentSensitiveAreas = sensitiveAreas.results;
22
+ .then(([difficulties, routes, practices, themes, sensitiveAreas, pois, informationDesks, trek]) => {
23
+ if (difficulties) {
24
+ state.difficulties = difficulties.results;
25
+ }
26
+ if (routes) {
27
+ state.routes = routes.results;
28
+ }
29
+ if (practices) {
30
+ state.practices = practices.results.map(practice => (Object.assign(Object.assign({}, practice), { selected: false })));
31
+ }
32
+ if (themes) {
33
+ state.themes = themes.results;
34
+ }
35
+ if (sensitiveAreas) {
36
+ state.currentSensitiveAreas = sensitiveAreas.results;
37
+ }
24
38
  state.currentPois = pois.results;
25
39
  state.currentInformationDesks = informationDesks.results;
26
40
  state.currentTrek = trek;
@@ -15,19 +15,28 @@ export class GrwTreksProvider {
15
15
  this.portals && (treksRequest += `&portals=${this.portals}`);
16
16
  this.routes && (treksRequest += `&routes=${this.routes}`);
17
17
  this.practices && (treksRequest += `&practices=${this.practices}`);
18
- treksRequest += `&fields=id,name,attachments,description_teaser,difficulty,duration,ascent,length_2d,practice,route,departure_geom&page_size=999`;
18
+ treksRequest += `&fields=id,name,attachments,description_teaser,difficulty,duration,ascent,length_2d,practice,themes,route,departure,departure_geom&page_size=999`;
19
19
  return Promise.all([
20
20
  fetch(`${this.api}trek_difficulty/?language=${this.language}&fields=id,label,pictogram`),
21
21
  fetch(`${this.api}trek_route/?language=${this.language}&fields=id,route,pictogram`),
22
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`),
23
24
  fetch(treksRequest),
24
25
  ])
25
26
  .then(responses => Promise.all(responses.map(response => response.json())))
26
- .then(([difficulties, routes, practices, treks]) => {
27
+ .then(([difficulties, routes, practices, themes, treks]) => {
27
28
  state.difficulties = difficulties.results;
28
29
  state.routes = routes.results;
29
- state.practices = practices.results;
30
+ state.practices = practices.results.map(practice => (Object.assign(Object.assign({}, practice), { selected: false })));
31
+ state.themes = themes.results;
32
+ state.durations = [
33
+ { id: 1, name: '0 - 1h', minValue: 0, maxValue: 1, selected: false },
34
+ { id: 2, name: '1 - 2h', minValue: 1, maxValue: 2, selected: false },
35
+ { id: 3, name: '2 - 5h', minValue: 2, maxValue: 5, selected: false },
36
+ { id: 4, name: '5 - 10h', minValue: 5, maxValue: 10, selected: false },
37
+ ];
30
38
  state.treks = treks.results;
39
+ state.currentTreks = treks.results;
31
40
  });
32
41
  }
33
42
  render() {
@@ -2,9 +2,12 @@ import { createStore } from '@stencil/store';
2
2
  const { state, onChange } = createStore({
3
3
  api: '',
4
4
  treks: [],
5
+ currentTreks: [],
5
6
  difficulties: [],
6
7
  routes: [],
7
8
  practices: [],
9
+ themes: [],
10
+ durations: [],
8
11
  currentSensitiveAreas: null,
9
12
  currentPois: null,
10
13
  currentTrek: null,
@@ -9,7 +9,6 @@ export const createApp = ({
9
9
  portals,
10
10
  routes,
11
11
  practices,
12
- appName,
13
12
  urlLayer,
14
13
  attribution,
15
14
  colorPrimary,
@@ -24,15 +23,14 @@ export const createApp = ({
24
23
  const app = document.createElement('grw-app');
25
24
  app.setAttribute('api', api);
26
25
  app.setAttribute('language', language);
27
- app.setAttribute('in-bbox', inBbox);
28
- app.setAttribute('cities', cities);
29
- app.setAttribute('districts', districts);
30
- app.setAttribute('structures', structures);
31
- app.setAttribute('themes', themes);
32
- app.setAttribute('portals', portals);
33
- app.setAttribute('routes', routes);
34
- app.setAttribute('practices', practices);
35
- app.setAttribute('app-name', appName);
26
+ inBbox && app.setAttribute('in-bbox', inBbox);
27
+ cities && app.setAttribute('cities', cities);
28
+ districts && app.setAttribute('districts', districts);
29
+ structures && app.setAttribute('structures', structures);
30
+ themes && app.setAttribute('themes', themes);
31
+ portals && app.setAttribute('portals', portals);
32
+ routes && app.setAttribute('routes', routes);
33
+ practices && app.setAttribute('practices', practices);
36
34
  app.setAttribute('url-layer', urlLayer);
37
35
  app.setAttribute('attribution', attribution);
38
36
  app.setAttribute('color-primary', colorPrimary);
@@ -5,9 +5,11 @@ export default {
5
5
  argTypes: {
6
6
  urlLayer: {
7
7
  control: 'select',
8
- options: ['openstreetmap'],
8
+ options: ['openstreetmap', 'planignv2'],
9
9
  mapping: {
10
10
  openstreetmap: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
11
+ planignv2:
12
+ 'https://wxs.ign.fr/cartes/geoportail/wmts?&REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&STYLE=normal&TILEMATRIXSET=PM&FORMAT=image/png&LAYER=GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}',
11
13
  },
12
14
  },
13
15
  },
@@ -30,9 +32,8 @@ App.args = {
30
32
  portals: '',
31
33
  routes: '',
32
34
  practices: '',
33
- appName: 'Geotrek Rando Widget',
34
35
  urlLayer: 'openstreetmap',
35
- attribution: '© OpenStreetMap',
36
+ attribution: '© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors',
36
37
  colorPrimary: '#6b0030',
37
38
  colorPrimaryShade: '4a0021',
38
39
  colorPrimaryTint: '#974c6e',
@@ -5,9 +5,10 @@ export default {
5
5
  argTypes: {
6
6
  urlLayer: {
7
7
  control: 'select',
8
- options: ['openstreetmap'],
8
+ options: ['openstreetmap', 'planignv2'],
9
9
  mapping: {
10
10
  openstreetmap: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
11
+ planignv2: 'https://wxs.ign.fr/cartes/geoportail/wmts?&REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&STYLE=normal&TILEMATRIXSET=PM&FORMAT=image/png&LAYER=GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}',
11
12
  },
12
13
  },
13
14
  },
@@ -25,7 +26,7 @@ TrekMap.args = {
25
26
  urlLayer: 'openstreetmap',
26
27
  center: '46.50761080179829, 5.927117067721017',
27
28
  zoom: 8,
28
- attribution: '© OpenStreetMap',
29
+ attribution: '© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors',
29
30
  colorTrekLine: '#6b0030',
30
31
  colorDepartureIcon: '#006b3b',
31
32
  colorArrivalIcon: '#85003b',
@@ -3,14 +3,14 @@ export const createTreksList = ({ api, language, inBbox, cities, districts, stru
3
3
  const treks = document.createElement('grw-treks-provider');
4
4
  treks.setAttribute('api', api);
5
5
  treks.setAttribute('language', language);
6
- treks.setAttribute('in-bbox', inBbox);
7
- treks.setAttribute('cities', cities);
8
- treks.setAttribute('districts', districts);
9
- treks.setAttribute('structures', structures);
10
- treks.setAttribute('themes', themes);
11
- treks.setAttribute('portals', portals);
12
- treks.setAttribute('routes', routes);
13
- treks.setAttribute('practices', practices);
6
+ inBbox && treks.setAttribute('in-bbox', inBbox);
7
+ cities && treks.setAttribute('cities', cities);
8
+ districts && treks.setAttribute('districts', districts);
9
+ structures && treks.setAttribute('structures', structures);
10
+ themes && treks.setAttribute('themes', themes);
11
+ portals && treks.setAttribute('portals', portals);
12
+ routes && treks.setAttribute('routes', routes);
13
+ practices && treks.setAttribute('practices', practices);
14
14
  container.appendChild(treks);
15
15
  const list = document.createElement('grw-treks-list');
16
16
  list.setAttribute('color-primary', colorPrimary);
@@ -5,9 +5,10 @@ export default {
5
5
  argTypes: {
6
6
  urlLayer: {
7
7
  control: 'select',
8
- options: ['openstreetmap'],
8
+ options: ['openstreetmap', 'planignv2'],
9
9
  mapping: {
10
10
  openstreetmap: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
11
+ planignv2: 'https://wxs.ign.fr/cartes/geoportail/wmts?&REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&STYLE=normal&TILEMATRIXSET=PM&FORMAT=image/png&LAYER=GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}',
11
12
  },
12
13
  },
13
14
  },
@@ -24,7 +25,7 @@ TreksMap.args = {
24
25
  urlLayer: 'openstreetmap',
25
26
  center: '46.50761080179829, 5.927117067721017',
26
27
  zoom: 8,
27
- attribution: '© OpenStreetMap',
28
+ attribution: '© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors',
28
29
  colorPrimary: '#6b0030',
29
30
  colorPrimaryTint: '#974c6e',
30
31
  };
@@ -1,5 +1,6 @@
1
1
  import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
2
2
  import { s as state } from './store.js';
3
+ import { d as defineCustomElement$b } from './grw-filter2.js';
3
4
  import { d as defineCustomElement$a } from './grw-information-desk-detail2.js';
4
5
  import { d as defineCustomElement$9 } from './grw-map2.js';
5
6
  import { d as defineCustomElement$8 } from './grw-poi-detail2.js';
@@ -12,7 +13,7 @@ import { d as defineCustomElement$2 } from './grw-treks-provider2.js';
12
13
 
13
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>`;
14
15
 
15
- 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 .title,.large-view-header-container .title{color:#ffffff;margin-left:24px}.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}.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;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
17
 
17
18
  const GrwApp$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
18
19
  constructor() {
@@ -21,6 +22,7 @@ const GrwApp$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
21
22
  this.__attachShadow();
22
23
  this.showTrek = false;
23
24
  this.showMap = false;
25
+ this.showFilters = false;
24
26
  this.isLargeView = false;
25
27
  this.language = 'fr';
26
28
  this.appName = 'Geotrek Rando Widget';
@@ -32,7 +34,7 @@ const GrwApp$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
32
34
  this.colorArrivalIcon = '#85003b';
33
35
  this.colorSensitiveArea = '#4974a5';
34
36
  this.colorPoiIcon = '#974c6e';
35
- this.largeViewSize = 664;
37
+ this.largeViewSize = 1024;
36
38
  }
37
39
  onTrekCardPress(event) {
38
40
  this.currentTrekId = event.detail;
@@ -55,8 +57,11 @@ const GrwApp$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
55
57
  this.isLargeView = this.element.getBoundingClientRect().width >= this.largeViewSize;
56
58
  this.showMap = this.isLargeView;
57
59
  }
60
+ handleFilters() {
61
+ this.showFilters = !this.showFilters;
62
+ }
58
63
  render() {
59
- return (h(Host, { style: { '--color-primary': this.colorPrimary, '--color-primary-tint': this.colorPrimaryTint } }, 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.onTrekDetailsClose(), class: "arrow-back-icon", innerHTML: arrowBackImage }) : h("div", { class: "title" }, this.appName)), 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", { "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.showMap ? 'visible' : 'hidden' }, "url-layer": this.urlLayer, center: this.center, zoom: this.zoom, attribution: this.attribution, "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.showMap = !this.showMap) }, this.showMap ? (this.showTrek ? 'Voir la fiche' : 'Voir la liste') : 'Voir la carte')))));
64
+ 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.onTrekDetailsClose(), 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.showMap ? '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.showMap = !this.showMap) }, this.showMap ? (this.showTrek ? 'Voir la fiche' : 'Voir la liste') : 'Voir la carte')))));
60
65
  }
61
66
  get element() { return this; }
62
67
  static get watchers() { return {
@@ -89,6 +94,7 @@ const GrwApp$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
89
94
  "colorPoiIcon": [1, "color-poi-icon"],
90
95
  "showTrek": [32],
91
96
  "showMap": [32],
97
+ "showFilters": [32],
92
98
  "isLargeView": [32],
93
99
  "currentTrekId": [32]
94
100
  }, [[0, "trekCardPress", "onTrekCardPress"], [9, "resize", "onWindowResize"]]]);
@@ -96,13 +102,18 @@ function defineCustomElement$1() {
96
102
  if (typeof customElements === "undefined") {
97
103
  return;
98
104
  }
99
- const components = ["grw-app", "grw-information-desk-detail", "grw-map", "grw-poi-detail", "grw-sensitive-area-detail", "grw-trek-card", "grw-trek-detail", "grw-trek-provider", "grw-treks-list", "grw-treks-provider"];
105
+ const components = ["grw-app", "grw-filter", "grw-information-desk-detail", "grw-map", "grw-poi-detail", "grw-sensitive-area-detail", "grw-trek-card", "grw-trek-detail", "grw-trek-provider", "grw-treks-list", "grw-treks-provider"];
100
106
  components.forEach(tagName => { switch (tagName) {
101
107
  case "grw-app":
102
108
  if (!customElements.get(tagName)) {
103
109
  customElements.define(tagName, GrwApp$1);
104
110
  }
105
111
  break;
112
+ case "grw-filter":
113
+ if (!customElements.get(tagName)) {
114
+ defineCustomElement$b();
115
+ }
116
+ break;
106
117
  case "grw-information-desk-detail":
107
118
  if (!customElements.get(tagName)) {
108
119
  defineCustomElement$a();
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface GrwFilter extends Components.GrwFilter, HTMLElement {}
4
+ export const GrwFilter: {
5
+ prototype: GrwFilter;
6
+ new (): GrwFilter;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,6 @@
1
+ import { G as GrwFilter$1, d as defineCustomElement$1 } from './grw-filter2.js';
2
+
3
+ const GrwFilter = GrwFilter$1;
4
+ const defineCustomElement = defineCustomElement$1;
5
+
6
+ export { GrwFilter, defineCustomElement };
@@ -0,0 +1,95 @@
1
+ import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
2
+ import { s as state } from './store.js';
3
+
4
+ const grwFilterCss = ".filter-name{margin-left:8px;color:var(--color-primary);font-size:24px;font-weight:bold}.filter-button-container{display:flex;flex-direction:row;flex-wrap:wrap}.filter-button-container .filter-button,.filter-button-container .selected-filter-button{user-select:none;cursor:pointer;border:1px var(--color-primary) solid;border-radius:8px;margin:8px 0px 0px 8px;padding:8px}.filter-button-container .filter-button{color:var(--color-primary);background-color:#ffffff}.filter-button-container .selected-filter-button{color:#ffffff;background-color:var(--color-primary)}";
5
+
6
+ const GrwFilter = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
7
+ constructor() {
8
+ super();
9
+ this.__registerHost();
10
+ this.__attachShadow();
11
+ this.filters = [
12
+ { property: 'practices', trekProperty: 'practice', type: 'include' },
13
+ { property: 'difficulties', trekProperty: 'difficulty', type: 'include' },
14
+ { property: 'durations', trekProperty: 'duration', type: 'interval' },
15
+ ];
16
+ }
17
+ handleFilter(_event, filterToHandle) {
18
+ const filterFromState = [...state[this.filterType]];
19
+ filterFromState.find(currentFilter => currentFilter.id === filterToHandle.id).selected = !filterFromState.find(currentFilter => currentFilter.id === filterToHandle.id)
20
+ .selected;
21
+ state[this.filterType] = filterFromState;
22
+ let isUsingFilter = false;
23
+ let filtersTreks = [];
24
+ for (const filter of this.filters) {
25
+ const currentFiltersId = state[filter.property].filter(currentFilter => currentFilter.selected).map(currentFilter => currentFilter.id);
26
+ if (currentFiltersId.length > 0) {
27
+ if (filtersTreks.length > 0) {
28
+ if (filter.type === 'include') {
29
+ filtersTreks = [...filtersTreks.filter(trek => currentFiltersId.includes(trek[filter.trekProperty]))];
30
+ }
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)];
44
+ }
45
+ }
46
+ else {
47
+ if (!isUsingFilter) {
48
+ isUsingFilter = true;
49
+ }
50
+ if (filter.type === 'include') {
51
+ filtersTreks = [...state.treks.filter(trek => currentFiltersId.includes(trek[filter.trekProperty]))];
52
+ }
53
+ else if (filter.type === 'interval') {
54
+ let minValue;
55
+ let maxValue;
56
+ for (const currentFilterId of currentFiltersId) {
57
+ const currentFilter = state[filter.property].find(property => property.id === currentFilterId);
58
+ if (isNaN(minValue) || currentFilter.minValue < minValue) {
59
+ minValue = currentFilter.minValue;
60
+ }
61
+ if (isNaN(maxValue) || currentFilter.maxValue > maxValue) {
62
+ maxValue = currentFilter.maxValue;
63
+ }
64
+ }
65
+ filtersTreks = [...state.treks.filter(trek => trek[filter.trekProperty] >= minValue && trek[filter.trekProperty] <= maxValue)];
66
+ }
67
+ }
68
+ }
69
+ }
70
+ state.currentTreks = isUsingFilter ? filtersTreks : state.treks;
71
+ }
72
+ render() {
73
+ return (h(Host, null, h("div", { class: "filter-name" }, this.filterName), h("div", { class: "filter-button-container" }, state[this.filterType].map(currentFilter => (h("div", { onClick: event => this.handleFilter(event, currentFilter), class: currentFilter.selected ? 'selected-filter-button' : 'filter-button' }, currentFilter[this.filterNameProperty]))))));
74
+ }
75
+ static get style() { return grwFilterCss; }
76
+ }, [1, "grw-filter", {
77
+ "filterType": [1, "filter-type"],
78
+ "filterName": [1, "filter-name"],
79
+ "filterNameProperty": [1, "filter-name-property"]
80
+ }]);
81
+ function defineCustomElement() {
82
+ if (typeof customElements === "undefined") {
83
+ return;
84
+ }
85
+ const components = ["grw-filter"];
86
+ components.forEach(tagName => { switch (tagName) {
87
+ case "grw-filter":
88
+ if (!customElements.get(tagName)) {
89
+ customElements.define(tagName, GrwFilter);
90
+ }
91
+ break;
92
+ } });
93
+ }
94
+
95
+ export { GrwFilter as G, defineCustomElement as d };
@@ -14176,11 +14176,11 @@ const GrwMap = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
14176
14176
  else if (state.currentTrek) {
14177
14177
  this.addTreks();
14178
14178
  }
14179
- onChange('treks', () => {
14179
+ onChange('currentTreks', () => {
14180
14180
  if (state.currentTrek) {
14181
14181
  this.addTrek();
14182
14182
  }
14183
- else if (state.treks) {
14183
+ else if (state.currentTreks) {
14184
14184
  this.addTreks();
14185
14185
  }
14186
14186
  });
@@ -14202,7 +14202,7 @@ const GrwMap = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
14202
14202
  type: 'FeatureCollection',
14203
14203
  features: [],
14204
14204
  };
14205
- for (const trek of state.treks) {
14205
+ for (const trek of state.currentTreks) {
14206
14206
  trekscurrentDepartureCoordinates.push(trek.departure_geom);
14207
14207
  treksFeatureCollection.features.push({
14208
14208
  type: 'Feature',
@@ -14211,7 +14211,7 @@ const GrwMap = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
14211
14211
  id: trek.id,
14212
14212
  name: trek.name,
14213
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].url,
14214
+ imgSrc: trek.attachments && trek.attachments.length > 0 && trek.attachments[0].thumbnail,
14215
14215
  },
14216
14216
  });
14217
14217
  }
@@ -14220,34 +14220,40 @@ const GrwMap = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
14220
14220
  this.currentBounds = bounds;
14221
14221
  this.map.fitBounds(this.currentBounds);
14222
14222
  }
14223
- this.treksLayer = leafletSrc.geoJSON(treksFeatureCollection, {
14224
- pointToLayer: (geoJsonPoint, latlng) => leafletSrc.marker(latlng, {
14225
- icon: leafletSrc.divIcon({
14226
- html: geoJsonPoint.properties.practice && `<img src=${geoJsonPoint.properties.practice} />`,
14227
- className: 'trek-marker',
14228
- iconSize: 48,
14223
+ if (!this.treksLayer) {
14224
+ this.treksLayer = leafletSrc.geoJSON(treksFeatureCollection, {
14225
+ pointToLayer: (geoJsonPoint, latlng) => leafletSrc.marker(latlng, {
14226
+ icon: leafletSrc.divIcon({
14227
+ html: geoJsonPoint.properties.practice && `<img src=${geoJsonPoint.properties.practice} />`,
14228
+ className: 'trek-marker',
14229
+ iconSize: 48,
14230
+ }),
14231
+ autoPanOnFocus: false,
14229
14232
  }),
14230
- autoPanOnFocus: false,
14231
- }),
14232
- onEachFeature: (geoJsonPoint, layer) => {
14233
- layer.once('click', () => {
14234
- const trekDeparturePopup = leafletSrc.DomUtil.create('div');
14235
- trekDeparturePopup.className = 'trek-departure-popup';
14236
- trekDeparturePopup.onclick = () => this.trekCardPress.emit(geoJsonPoint.properties.id);
14237
- const trekName = leafletSrc.DomUtil.create('div');
14238
- trekName.innerHTML = geoJsonPoint.properties.name;
14239
- trekName.className = 'trek-name';
14240
- if (geoJsonPoint.properties.imgSrc) {
14241
- trekName.className += ' trek-name-margin-top';
14242
- const trekImg = leafletSrc.DomUtil.create('img');
14243
- trekImg.src = geoJsonPoint.properties.imgSrc;
14244
- trekDeparturePopup.appendChild(trekImg);
14245
- }
14246
- trekDeparturePopup.appendChild(trekName);
14247
- layer.bindPopup(trekDeparturePopup, { interactive: true, autoPan: false, closeButton: false }).openPopup();
14248
- });
14249
- },
14250
- }).addTo(this.map);
14233
+ onEachFeature: (geoJsonPoint, layer) => {
14234
+ layer.once('click', () => {
14235
+ const trekDeparturePopup = leafletSrc.DomUtil.create('div');
14236
+ trekDeparturePopup.className = 'trek-departure-popup';
14237
+ trekDeparturePopup.onclick = () => this.trekCardPress.emit(geoJsonPoint.properties.id);
14238
+ const trekName = leafletSrc.DomUtil.create('div');
14239
+ trekName.innerHTML = geoJsonPoint.properties.name;
14240
+ trekName.className = 'trek-name';
14241
+ if (geoJsonPoint.properties.imgSrc) {
14242
+ trekName.className += ' trek-name-margin-top';
14243
+ const trekImg = leafletSrc.DomUtil.create('img');
14244
+ trekImg.src = geoJsonPoint.properties.imgSrc;
14245
+ trekDeparturePopup.appendChild(trekImg);
14246
+ }
14247
+ trekDeparturePopup.appendChild(trekName);
14248
+ layer.bindPopup(trekDeparturePopup, { interactive: true, autoPan: false, closeButton: false }).openPopup();
14249
+ });
14250
+ },
14251
+ }).addTo(this.map);
14252
+ }
14253
+ else {
14254
+ this.treksLayer.clearLayers();
14255
+ this.treksLayer.addData(treksFeatureCollection);
14256
+ }
14251
14257
  !this.mapIsReady && (this.mapIsReady = !this.mapIsReady);
14252
14258
  }
14253
14259
  removeTreks() {