mobility-toolbox-js 3.0.0-beta.35 → 3.0.0-beta.37

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.
@@ -27,7 +27,7 @@ export type RoutingControlOptions = {
27
27
  style?: StyleLike;
28
28
  useRawViaPoints?: boolean;
29
29
  } & Options;
30
- export type AbotControllersByGraph = Record<string, AbortController>;
30
+ export type AbortControllersByGraph = Record<string, AbortController>;
31
31
  /**
32
32
  * This OpenLayers control allows the user to add and modifiy via points to
33
33
  * a map and request a route from the [geOps Routing API](https://developer.geops.io/apis/routing/).
@@ -250,7 +250,7 @@ class RoutingControl extends Control {
250
250
  */
251
251
  // Define and add modify interaction
252
252
  this.modifyInteraction = new Modify({
253
- // hitDetection: this.routingLayer, // Create a bug, the first point is always selected even if the mous eis far away
253
+ // hitDetection: this.routingLayer, // TODO: wait for ol, fixed in https://github.com/openlayers/openlayers/pull/16393
254
254
  deleteCondition: (e) => {
255
255
  var _a;
256
256
  const feats = ((_a = e.target) === null || _a === void 0 ? void 0 : _a.getFeaturesAtPixel(e.pixel, {
@@ -294,7 +294,7 @@ class RoutingControl extends Control {
294
294
  var _a, _b;
295
295
  /* Calls RoutingAPI to draw a route using the viaPoints array */
296
296
  this.abortRequests();
297
- (_b = (_a = this.routingLayer) === null || _a === void 0 ? void 0 : _a.getSource()) === null || _b === void 0 ? void 0 : _b.clear(true);
297
+ (_b = (_a = this.routingLayer) === null || _a === void 0 ? void 0 : _a.getSource()) === null || _b === void 0 ? void 0 : _b.clear();
298
298
  if (!this.viaPoints.length) {
299
299
  return null;
300
300
  }
@@ -1,9 +1,8 @@
1
1
  import { MapLibreLayer } from '@geoblocks/ol-maplibre-layer';
2
2
  import OlMap from 'ol/Map';
3
3
  import { MobilityLayerOptions } from '../mixins/MobilityLayerMixin';
4
- import type { MapLibreOptions } from '@geoblocks/ol-maplibre-layer/lib/types/MapLibreLayer';
4
+ import type { MapLibreLayerOptions, MapLibreOptions } from '@geoblocks/ol-maplibre-layer/lib/types/MapLibreLayer';
5
5
  import type { QueryRenderedFeaturesOptions } from 'maplibre-gl';
6
- import type { Options as LayerOptions } from 'ol/layer/Layer';
7
6
  export type MaplibreLayerOptions = {
8
7
  apiKey?: string;
9
8
  apiKeyName?: string;
@@ -11,7 +10,7 @@ export type MaplibreLayerOptions = {
11
10
  queryRenderedFeaturesOptions?: QueryRenderedFeaturesOptions | undefined;
12
11
  style?: maplibregl.StyleSpecification | null | string;
13
12
  url?: string;
14
- } & LayerOptions & MobilityLayerOptions;
13
+ } & MapLibreLayerOptions & MobilityLayerOptions;
15
14
  declare const MaplibreLayer_base: {
16
15
  new (...args: any[]): {
17
16
  olEventsKeys: import("ol/events").EventsKey[];
@@ -19,9 +18,9 @@ declare const MaplibreLayer_base: {
19
18
  attachToMap(map: OlMap): void;
20
19
  detachFromMap(): void;
21
20
  flat(): any[];
22
- onChildrenChange(oldValue: import("ol/layer/Layer").default[]): void;
21
+ onChildrenChange(oldValue: import("ol/layer").Layer[]): void;
23
22
  setMapInternal: ((map: OlMap) => void) & ((map: import("ol/Map").default | null) => void);
24
- children: import("ol/layer/Layer").default<import("ol/source").Source, import("ol/renderer/Layer").default<any>>[];
23
+ children: import("ol/layer").Layer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>[];
25
24
  get copyrights(): string;
26
25
  set copyrights(newCopyrights: string | string[]);
27
26
  disabled: boolean;
@@ -30,8 +29,8 @@ declare const MaplibreLayer_base: {
30
29
  readonly key: string;
31
30
  readonly map: OlMap;
32
31
  readonly name: string;
33
- olLayer: import("ol/layer/Layer").default;
34
- parent: import("ol/layer/Layer").default<import("ol/source").Source, import("ol/renderer/Layer").default<any>>;
32
+ olLayer: import("ol/layer").Layer;
33
+ parent: import("ol/layer").Layer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>;
35
34
  visible: boolean;
36
35
  on: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
37
36
  once: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
@@ -55,7 +54,7 @@ declare const MaplibreLayer_base: {
55
54
  getBackground: () => import("ol/layer/Base").BackgroundColor | false;
56
55
  getClassName: () => string;
57
56
  getLayerState: (managed?: boolean | undefined) => import("ol/layer/Layer").State;
58
- getLayersArray: (array?: import("ol/layer/Layer").default<import("ol/source").default, import("ol/renderer/Layer").default<any>>[] | undefined) => Array<import("ol/layer/Layer").default>;
57
+ getLayersArray: (array?: import("ol/layer").default<import("ol/source").default, import("ol/renderer/Layer").default<any>>[] | undefined) => Array<import("ol/layer").default>;
59
58
  getLayerStatesArray: (states?: import("ol/layer/Layer").State[] | undefined) => Array<import("ol/layer/Layer").State>;
60
59
  getExtent: () => import("ol/extent").Extent | undefined;
61
60
  getMaxResolution: () => number;
@@ -158,7 +157,7 @@ declare class MaplibreLayer extends MaplibreLayer_base {
158
157
  * @public
159
158
  */
160
159
  clone(newOptions: MaplibreLayerOptions): MaplibreLayer;
161
- getStyle(): string;
160
+ getStyle(): any;
162
161
  updateMaplibreMap(): void;
163
162
  set apiKey(newValue: string);
164
163
  get apiKey(): string;
@@ -71,6 +71,9 @@ class MaplibreLayer extends MobilityLayerMixin(MapLibreLayer) {
71
71
  newOptions.mapLibreOptions.style = buildStyleUrl(newOptions.url, newOptions.style, newOptions.apiKey, newOptions.apiKeyName);
72
72
  }
73
73
  super(newOptions);
74
+ // We save the options to be able to clone the layer.
75
+ // and to see if the style is defined by the maplibreOptions given by the user.
76
+ this.set('options', options);
74
77
  }
75
78
  /**
76
79
  * Initialize the layer and listen to feature clicks.
@@ -105,6 +108,7 @@ class MaplibreLayer extends MobilityLayerMixin(MapLibreLayer) {
105
108
  return new MaplibreLayer(Object.assign(Object.assign({}, (this.options || {})), (newOptions || {})));
106
109
  }
107
110
  getStyle() {
111
+ var _a, _b;
108
112
  // If the style is a complete style object, use it directly.
109
113
  if (this.style &&
110
114
  typeof this.style === 'object' &&
@@ -116,6 +120,10 @@ class MaplibreLayer extends MobilityLayerMixin(MapLibreLayer) {
116
120
  if (this.url.includes('style.json')) {
117
121
  return this.url;
118
122
  }
123
+ // If the user has defined the style by the maplibreOptions, we use it directly.
124
+ if ((_b = (_a = this.get('options')) === null || _a === void 0 ? void 0 : _a.mapLibreOptions) === null || _b === void 0 ? void 0 : _b.style) {
125
+ return this.get('options').mapLibreOptions.style;
126
+ }
119
127
  /// Otherwise build the complete style url.
120
128
  return buildStyleUrl(this.url, this.style, this.apiKey, this.apiKeyName);
121
129
  }
@@ -84,7 +84,7 @@ declare function PropertiesLayerMixin<TBase extends Layerable>(Base: TBase): {
84
84
  getBackground: () => import("ol/layer/Base").BackgroundColor | false;
85
85
  getClassName: () => string;
86
86
  getLayerState: (managed?: boolean | undefined) => import("ol/layer/Layer").State;
87
- getLayersArray: (array?: import("ol/layer/Layer").default<import("ol/source").default, import("ol/renderer/Layer").default<any>>[] | undefined) => Array<import("ol/layer/Layer" /** @deprecated */).default>;
87
+ getLayersArray: (array?: import("ol/layer/Layer").default<import("ol/source").default, import("ol/renderer/Layer").default<any>>[] | undefined) => Array<import("ol/layer/Layer").default>;
88
88
  getLayerStatesArray: (states?: import("ol/layer/Layer").State[] | undefined) => Array<import("ol/layer/Layer").State>;
89
89
  getExtent: () => import("ol/extent").Extent | undefined;
90
90
  getMaxResolution: () => number;
@@ -1,6 +1,5 @@
1
1
  // eslint-disable-next-line max-classes-per-file
2
2
  import debounce from 'lodash.debounce';
3
- import { getUid } from 'ol';
4
3
  import { unByKey } from 'ol/Observable';
5
4
  import getLayersAsFlatArray from '../../common/utils/getLayersAsFlatArray';
6
5
  let deprecated = () => { };
@@ -134,7 +133,7 @@ function PropertiesLayerMixin(Base) {
134
133
  this.set('hitTolerance', newValue);
135
134
  }
136
135
  get key() {
137
- return this.get('key') || this.get('name') || getUid(this);
136
+ return this.get('key') || this.get('name');
138
137
  }
139
138
  get map() {
140
139
  return this.getMapInternal();
@@ -32,16 +32,24 @@ const dashedRedLine = new Style({
32
32
  }),
33
33
  });
34
34
  const routingStyle = (feature, resolution) => {
35
+ var _a;
35
36
  const minResolution = feature.get('minResolution');
36
37
  const maxResolution = feature.get('maxResolution');
37
38
  const inRange = resolution <= minResolution && resolution > maxResolution;
38
39
  if (minResolution && maxResolution && !inRange) {
39
40
  return [];
40
41
  }
42
+ const zIndex = ((_a = feature === null || feature === void 0 ? void 0 : feature.getGeometry()) === null || _a === void 0 ? void 0 : _a.getType()) === 'Point' ? 100 : 0;
43
+ let styles = [blackBorder, redLine];
41
44
  const mot = feature.get('mot');
42
- if (mot !== 'foot') {
43
- return [blackBorder, redLine];
45
+ if (mot === 'foot') {
46
+ styles = [dashedRedLine];
44
47
  }
45
- return [dashedRedLine];
48
+ styles = styles.map((style) => {
49
+ const tmp = style.clone();
50
+ tmp.setZIndex(zIndex);
51
+ return tmp;
52
+ });
53
+ return styles;
46
54
  };
47
55
  export default routingStyle;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "mobility-toolbox-js",
3
3
  "license": "MIT",
4
4
  "description": "Toolbox for JavaScript applications in the domains of mobility and logistics.",
5
- "version": "3.0.0-beta.35",
5
+ "version": "3.0.0-beta.37",
6
6
  "homepage": "https://mobility-toolbox-js.geops.io/",
7
7
  "exports": {
8
8
  ".": "./index.js",
@@ -26,8 +26,8 @@
26
26
  "devDependencies": {
27
27
  "@babel/preset-env": "^7.26.0",
28
28
  "@babel/preset-typescript": "^7.26.0",
29
- "@commitlint/cli": "19.5.0",
30
- "@commitlint/config-conventional": "19.5.0",
29
+ "@commitlint/cli": "19.6.0",
30
+ "@commitlint/config-conventional": "19.6.0",
31
31
  "@geops/eslint-config-react": "^1.2.0",
32
32
  "@types/geojson": "7946.0.14",
33
33
  "@types/lodash": "^4.17.13",
@@ -37,9 +37,9 @@
37
37
  "@types/offscreencanvas": "2019.7.3",
38
38
  "@types/topojson": "3.2.6",
39
39
  "@types/uuid": "10.0.0",
40
- "@typescript-eslint/eslint-plugin": "8.14.0",
41
- "@typescript-eslint/parser": "8.14.0",
42
- "cypress": "13.15.2",
40
+ "@typescript-eslint/eslint-plugin": "8.15.0",
41
+ "@typescript-eslint/parser": "8.15.0",
42
+ "cypress": "13.16.0",
43
43
  "esbuild": "0.24.0",
44
44
  "esdoc": "1.1.0",
45
45
  "esdoc-ecmascript-proposal-plugin": "1.0.0",
@@ -56,7 +56,7 @@
56
56
  "eslint-plugin-prettier": "5.2.1",
57
57
  "eslint-plugin-react": "7.37.2",
58
58
  "fixpack": "4.0.0",
59
- "husky": "9.1.6",
59
+ "husky": "9.1.7",
60
60
  "is-ci": "3.0.1",
61
61
  "jest": "29.7.0",
62
62
  "jest-canvas-mock": "2.5.2",
@@ -80,9 +80,10 @@
80
80
  "stylelint": "16.10.0",
81
81
  "stylelint-config-recommended-scss": "14.1.0",
82
82
  "stylelint-config-standard": "36.0.1",
83
- "stylelint-scss": "6.9.0",
83
+ "stylelint-scss": "6.10.0",
84
84
  "ts-jest": "^29.2.5",
85
- "typescript": "5.6.3"
85
+ "typescript": "5.6.3",
86
+ "vite": "^5.4.11"
86
87
  },
87
88
  "scripts": {
88
89
  "apidoc": "esdoc && cp apidoc/index.json doc/src/components/Esdoc",
@@ -95,9 +96,10 @@
95
96
  "cy:test:chrome": "yarn build && start-server-and-test start http://localhost:3000 'cypress run --browser chrome'",
96
97
  "cy:test:edge": "yarn build && start-server-and-test start http://localhost:3000 'cypress run --browser edge'",
97
98
  "cy:test:firefox": "yarn build && start-server-and-test start http://localhost:3000 'cypress run --browser firefox'",
98
- "dev": "yarn clean && yarn build && yarn apidoc && yarn dev:examples",
99
- "dev:examples": "yarn clean && yarn build && cd doc && rm -rf node_modules/mobility-toolbox-js && yarn install --force && yarn dev",
99
+ "dev": "vite",
100
100
  "doc": "yarn build && yarn apidoc && cd doc && rm -rf node_modules/mobility-toolbox-js && yarn install --force && yarn build",
101
+ "doc:dev": "yarn clean && yarn build && yarn apidoc && yarn dev:examples",
102
+ "doc:dev:examples": "yarn clean && yarn build && cd doc && rm -rf node_modules/mobility-toolbox-js && yarn install --force && yarn dev",
101
103
  "esbuild": "yarn esbuild:all && yarn esbuild:iife",
102
104
  "esbuild:all": "esbuild src/index.js src/**/*.js src/**/*.ts src/**/**/*.js src/**/**/*.ts --target=chrome100 --outdir=build/ --loader:.js=jsx",
103
105
  "esbuild:iife": "yarn esbuild:iife:unminify && yarn esbuild:iife:minify",
@@ -105,9 +107,6 @@
105
107
  "esbuild:iife:minify": "yarn esbuild:iife:base --minify --outfile=build/mbt.min.js",
106
108
  "esbuild:iife:unminify": "yarn esbuild:iife:base --outfile=build/mbt.js",
107
109
  "format": "prettier --write 'src/**/*.js' 'src/**/*.test.js' && eslint src/**/*.js src/**/*.test.js src/**/*.ts --fix && stylelint 'src/**/*.css' 'src/**/*.scss' --fix --allow-empty-input",
108
- "lib": "REACT_APP_LIB_MODE=1 webpack --mode production",
109
- "lib:dev": "REACT_APP_LIB_MODE=1 webpack --mode development",
110
- "link2": "cmdToAdd=$(node ./scripts/read-pkg-json.js add) && $cmdToAdd && yarn build && cmdToRemove=$(node ./scripts/read-pkg-json.js remove) && $cmdToRemove && cd build && yarn link",
111
110
  "lint": "eslint src/**/*.js src/**/*.ts && stylelint src/**/*.css src/**/*.scss --allow-empty-input",
112
111
  "prepare": "is-ci || husky",
113
112
  "publish:beta": "HUSKY=0 yarn release -- --prerelease beta --skip.changelog && yarn run build && cd build && HUSKY=0 yarn publish --tag beta && git push origin HEAD && git push --tags ",