@geops/rvf-mobility-web-component 0.1.65 → 0.1.67

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,25 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.1.67](https://github.com/geops/rvf-mobility-web-component/compare/v0.1.66...v0.1.67) (2025-10-16)
6
+
7
+
8
+ ### Features
9
+
10
+ * add mapset timestamp attribute ([6e25a8b](https://github.com/geops/rvf-mobility-web-component/commit/6e25a8bc75eeef75a4cd367838403443b9aca08f))
11
+ * add mapsettags attribute and fix bbox transformation on load ([23809bd](https://github.com/geops/rvf-mobility-web-component/commit/23809bdbc8a2616da24e7c0929c216245026b2b6))
12
+
13
+ ### [0.1.66](https://github.com/geops/rvf-mobility-web-component/compare/v0.1.65...v0.1.66) (2025-10-15)
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * add documentation for url paramters ([e759e58](https://github.com/geops/rvf-mobility-web-component/commit/e759e589105c7551819ca83df0b36769fb45a0b0))
19
+ * add documentation for url paramters ([b4083e2](https://github.com/geops/rvf-mobility-web-component/commit/b4083e2521fc10b445be9edd464b8e94d88dcf66))
20
+ * add documentation for url paramters ([6eb1629](https://github.com/geops/rvf-mobility-web-component/commit/6eb1629afda1afec9caddf1e0807546d70c434fd))
21
+ * add noapply url parameter documentation ([6e42a63](https://github.com/geops/rvf-mobility-web-component/commit/6e42a6307438989265b3546f4ca789c6ddf71662))
22
+ * fix layer config title display when there is not translation ([feba3da](https://github.com/geops/rvf-mobility-web-component/commit/feba3dafc92ad1e941899eb9de2e99ccaccf2b67))
23
+
5
24
  ### [0.1.65](https://github.com/geops/rvf-mobility-web-component/compare/v0.1.64...v0.1.65) (2025-10-14)
6
25
 
7
26
 
package/docutils.js CHANGED
@@ -1,6 +1,8 @@
1
- const activateAttrUrlParameters = true;
1
+ /* Will ignore web component attributes defined as url parameters */
2
+ const doNotApplyAttributesUrlParameters =
3
+ new URLSearchParams(window.location.search).get("noapply") === "true";
2
4
 
3
- function onLoad(wc, attributes, events, pkgSrc) {
5
+ function onLoad(wc, attributes, events, pkgSrc, urlParameters = {}) {
4
6
  /* Show private attributes for dev purpose */
5
7
  const showPrivate =
6
8
  new URLSearchParams(window.location.search).get("private") === "true";
@@ -10,7 +12,7 @@ function onLoad(wc, attributes, events, pkgSrc) {
10
12
  const booleanAttrs = Object.entries(attributes)
11
13
  .filter(([, attr]) => attr.type === "boolean")
12
14
  .map(([key]) => key);
13
- const booleanTrueByDefault = booleanAttrs.filter(
15
+ const booleanTrueByDefaultAttrs = booleanAttrs.filter(
14
16
  (key) => attributes[key].defaultValue === "true",
15
17
  );
16
18
  const reloadAttrs = Object.entries(attributes)
@@ -37,6 +39,25 @@ function onLoad(wc, attributes, events, pkgSrc) {
37
39
  {},
38
40
  );
39
41
 
42
+ const attrsContent = generateAttributesTable(
43
+ wc,
44
+ attrs,
45
+ booleanAttrs,
46
+ booleanTrueByDefaultAttrs,
47
+ descriptionByAttr,
48
+ defaultValueByAttr,
49
+ reloadAttrs,
50
+ );
51
+
52
+ if (attrsContent) {
53
+ const elt = document.querySelector("#attributes");
54
+ if (elt) {
55
+ elt.innerHTML = attrsContent;
56
+ }
57
+ } else {
58
+ document.querySelector("#attributesDoc")?.remove();
59
+ }
60
+
40
61
  /* Events */
41
62
  const evts = Object.keys(events);
42
63
  const descriptionByEvent = Object.entries(events)
@@ -51,30 +72,66 @@ function onLoad(wc, attributes, events, pkgSrc) {
51
72
  return acc;
52
73
  }, {});
53
74
 
54
- /* Build HTML */
55
- const attrsContent = generateAttributesTable(
56
- wc,
57
- attrs,
58
- booleanAttrs,
59
- booleanTrueByDefault,
60
- descriptionByAttr,
61
- defaultValueByAttr,
62
- reloadAttrs,
63
- );
64
-
65
- if (attrsContent) {
66
- document.querySelector("#attributes").innerHTML = attrsContent;
75
+ const evtsContent = generateEventsTable(wc, evts, descriptionByEvent);
76
+ if (evtsContent) {
77
+ const elt = document.querySelector("#events");
78
+ if (elt) {
79
+ elt.innerHTML = evtsContent;
80
+ }
67
81
  } else {
68
- document.querySelector("#attributesDoc").remove();
82
+ document.querySelector("#eventsDoc")?.remove();
69
83
  }
70
84
 
71
- const evtsContent = generateEventsTable(wc, evts, descriptionByEvent);
72
- if (evtsContent) {
73
- document.querySelector("#events").innerHTML = evtsContent;
85
+ /* URL Parameters */
86
+ const params = Object.keys(urlParameters);
87
+ const booleanParams = Object.entries(urlParameters)
88
+ .filter(([, attr]) => attr.type === "boolean")
89
+ .map(([key]) => key);
90
+ const booleanTrueByDefaultParams = booleanParams.filter(
91
+ (key) => urlParameters[key].defaultValue === "true",
92
+ );
93
+ const reloadParams = Object.entries(urlParameters).map(([key]) => key);
94
+
95
+ const descriptionByParam = Object.entries(urlParameters)
96
+ .filter(([key, attr]) => {
97
+ if (showPrivate) {
98
+ return true;
99
+ }
100
+ return attr.public;
101
+ })
102
+ .reduce((acc, [key, attr]) => {
103
+ acc[key] = attr.description;
104
+ return acc;
105
+ }, {});
106
+
107
+ const defaultValueByParam = Object.entries(urlParameters).reduce(
108
+ (acc, [key, attr]) => {
109
+ acc[key] = attr.defaultValue;
110
+ return acc;
111
+ },
112
+ {},
113
+ );
114
+
115
+ const urlParamsContent = generateAttributesTable(
116
+ wc,
117
+ params,
118
+ booleanParams,
119
+ booleanTrueByDefaultParams,
120
+ descriptionByParam,
121
+ defaultValueByParam,
122
+ reloadParams,
123
+ );
124
+ if (urlParamsContent) {
125
+ const elt = document.querySelector("#urlParameters");
126
+ if (elt) {
127
+ elt.innerHTML = urlParamsContent;
128
+ }
74
129
  } else {
75
- document.querySelector("#eventsDoc").remove();
130
+ document.querySelector("#urlParamtersDoc")?.remove();
76
131
  }
77
132
 
133
+ /* Build HTML */
134
+
78
135
  document.querySelector("#code").innerHTML = generateCodeText(
79
136
  wc,
80
137
  attrs,
@@ -128,7 +185,7 @@ function applyPermalinkParameters(wc, attributes) {
128
185
  }
129
186
 
130
187
  // Apply all url parameters as attribute of the web component and fill the input fields.
131
- if (activateAttrUrlParameters) {
188
+ if (!doNotApplyAttributesUrlParameters) {
132
189
  params.forEach((value, key) => {
133
190
  if (!(key in attributes)) {
134
191
  return;
@@ -191,7 +248,11 @@ function generateAttributesTable(
191
248
  const defaultChecked = booleanTrueByDefault.includes(key)
192
249
  ? "checked"
193
250
  : "";
194
- const currValue = wc.getAttribute(key);
251
+ let currValue = wc.getAttribute(key);
252
+ const isUrlParameters = reloadAttrs?.includes(key);
253
+ if (isUrlParameters) {
254
+ currValue = new URLSearchParams(window.location.search).get(key);
255
+ }
195
256
  let checked = currValue === "true" ? "checked" : "";
196
257
  if (currValue !== "true" && currValue !== "false") {
197
258
  checked = defaultChecked;
@@ -201,28 +262,31 @@ function generateAttributesTable(
201
262
  <td class="border px-4 py-2">${key}</td>
202
263
  <!--td class="border px-4 py-2"></td>
203
264
  <td class="border px-4 py-2"></td-->
204
- <td class="border px-4 py-2">
205
- <div class="flex gap-4">
265
+ <td class="border px-4 py-2 space-y-2">
206
266
  ${
207
267
  isBoolean
208
268
  ? `<input
209
269
  type="checkbox"
210
- class="border"
270
+ id="${key}"
271
+ class="border mr-4 cursor-pointer inline-block"
211
272
  name="${key}"
212
273
  ${checked ? "checked" : ""}
213
274
  onchange="document.querySelector('${wc.localName}').setAttribute('${key}', this.checked);onAttributeUpdate(document.querySelector('${wc.localName}'),this.name, this.checked, '${reloadAttrs.join(",")}');"
214
275
  />`
215
276
  : `
216
- <input
217
- type="text"
218
- class="border"
219
- name="${key}"
220
- value="${wc.getAttribute(key) || defaultValueByAttr[key] || ""}"
221
- />
222
- <button class="border p-2 bg-black hover:bg-gray-700 text-white" onclick="document.querySelector('${wc.localName}').setAttribute('${key}', this.previousElementSibling.value);onAttributeUpdate(document.querySelector('${wc.localName}'),this.previousElementSibling.name, this.previousElementSibling.value, '${reloadAttrs.join(",")}');">Update</button>`
277
+ <div class="flex gap-4 mb-2">
278
+ <input
279
+ type="text"
280
+ class="border px-2"
281
+ name="${key}"
282
+ placeholder="${defaultValueByAttr[key] || ""}"
283
+ value="${wc.getAttribute(key) || defaultValueByAttr[key] || ""}"
284
+ />
285
+ <button class="border cursor-pointer p-2 bg-black hover:bg-gray-700 text-white" onclick="document.querySelector('${wc.localName}').setAttribute('${key}', this.previousElementSibling.value);onAttributeUpdate(document.querySelector('${wc.localName}'),this.previousElementSibling.name, this.previousElementSibling.value, '${reloadAttrs.join(",")}');">Update</button>
286
+ </div>`
223
287
  }
224
- </div>
225
- ${descriptionByAttr[key] ? `<div class="pt-2">${descriptionByAttr[key]}</div>` : ``}
288
+
289
+ ${descriptionByAttr[key] ? `<label for="${key}" class="cursor-pointer">${descriptionByAttr[key]}</label>` : ``}
226
290
  </td>
227
291
  </tr>
228
292
  `;
@@ -342,7 +406,7 @@ function onAttributeUpdate(wc, key, value, reloadAttrs) {
342
406
  window.location.reload();
343
407
  } else {
344
408
  wc.setAttribute(key, value);
345
- if (activateAttrUrlParameters) {
409
+ if (!doNotApplyAttributesUrlParameters) {
346
410
  window.history.replaceState(
347
411
  {},
348
412
  "",
package/index.html CHANGED
@@ -34,7 +34,7 @@
34
34
  <body class="p-8">
35
35
  <!-- tailwind hack to add class used in docutils -->
36
36
  <div
37
- class="absolute inset-0 flex h-full w-full table-auto gap-4 flex-col border bg-black p-0 px-4 py-2 pt-2 text-white hover:bg-gray-700"
37
+ class="absolute inset-0 flex h-full w-full table-auto mr-4 gap-4 space-y-4 flex-col border bg-black p-0 px-4 py-2 pt-2 text-white hover:bg-gray-700"
38
38
  style="display: none"
39
39
  ></div>
40
40
  </script>
@@ -53,20 +53,33 @@
53
53
  class="block h-128 w-full resize overflow-hidden rounded-[16px] border"
54
54
  ></geops-mobility>
55
55
 
56
- <br />
57
- <div id="attributesDoc">
56
+ <div id="attributesDoc" class="space-y-4">
58
57
  <h2 class="text-xl font-bold">Attributes</h2>
58
+
59
+ <pre class="rounded bg-slate-800 p-4 text-slate-200">
60
+ // Modify an attribute
61
+ document.getElementById('map').setAttribute("zoom", "15");
62
+ </pre
63
+ >
59
64
  <div id="attributes"></div>
60
65
  </div>
61
- <div id="eventsDoc">
66
+ <div id="eventsDoc" class="space-y-4">
62
67
  <h2 class="text-xl font-bold">Events</h2>
63
68
  <pre class="rounded bg-slate-800 p-4 text-slate-200">
69
+ // Listen to an event
64
70
  document.getElementById('map').addEventListener('mwc:attribute', (event) => {
65
71
  console.log('Display last data received:', event.data);
66
- });</pre
72
+ });
73
+ </pre
67
74
  >
68
75
  <div id="events"></div>
69
76
  </div>
77
+
78
+ <div id="urlParametersDoc" class="space-y-4">
79
+ <h2 class="text-xl font-bold">Documentation URL parameters</h2>
80
+ <p>The following parameters are only used by this documentation webpage.</p>
81
+ <div id="urlParameters"></div>
82
+ </div>
70
83
  <br />
71
84
  <br />
72
85
  <h1 class="text-xl font-bold">More mobility web components</h1>
@@ -87,24 +100,39 @@ document.getElementById('map').addEventListener('mwc:attribute', (event) => {
87
100
  const events = window.MobilityMapEvents;
88
101
 
89
102
  // Add page parameters
90
- attributes.fullscreen = {
91
- type: "boolean",
92
- defaultValue: "false",
93
- description: `Load the page in fullscreen mode.`,
94
- reload: true,
95
- public: false,
96
- };
103
+ const urlParameters = {
104
+ fullscreen: {
105
+ type: "boolean",
106
+ defaultValue: "false",
107
+ description: `Load the map in fullscreen mode.`,
108
+ public: true,
109
+ },
110
+ noapply: {
111
+ type: "boolean",
112
+ defaultValue: "false",
113
+ description:
114
+ "Will not apply web component attributes defined as url parameters. Useful to test the permalink functionality of the web component.",
115
+ public: true,
116
+ },
117
+
118
+ debug: {
119
+ type: "boolean",
120
+ defaultValue: "false",
121
+ description:
122
+ "Displays debug information for vehicles when true, use only for debugging.",
123
+ public: true,
124
+ },
97
125
 
98
- attributes.debug = {
99
- type: "boolean",
100
- defaultValue: "false",
101
- description:
102
- "Displays debug information for vehicles when true, use only for debugging.",
103
- reload: true,
104
- public: false,
126
+ private: {
127
+ type: "boolean",
128
+ defaultValue: "false",
129
+ description:
130
+ "Displays all private attributes, if there are some, use only for development purpose.",
131
+ public: true,
132
+ },
105
133
  };
106
134
 
107
- onLoad(wc, attributes, events, pkgSrc);
135
+ onLoad(wc, attributes, events, pkgSrc, urlParameters);
108
136
  });
109
137
  </script>
110
138
  </body>