@community-release/nx-ui 0.0.33 → 0.0.35

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/dist/module.d.mts CHANGED
@@ -117,7 +117,6 @@ var generateComponentsDefaults = (options) => {
117
117
  `;
118
118
  }
119
119
  }
120
- console.log("componentsStyle", result);
121
120
  return result;
122
121
  };
123
122
 
package/dist/module.d.ts CHANGED
@@ -117,7 +117,6 @@ var generateComponentsDefaults = (options) => {
117
117
  `;
118
118
  }
119
119
  }
120
- console.log("componentsStyle", result);
121
120
  return result;
122
121
  };
123
122
 
package/dist/module.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "ui",
3
3
  "configKey": "ui",
4
- "version": "0.0.33"
4
+ "version": "0.0.35"
5
5
  }
package/dist/module.mjs CHANGED
@@ -117,7 +117,6 @@ const generateComponentsDefaults = (options) => {
117
117
  `;
118
118
  }
119
119
  }
120
- console.log("componentsStyle", result);
121
120
  return result;
122
121
  };
123
122
 
@@ -0,0 +1,2 @@
1
+ declare function _default(ms?: number): any;
2
+ export default _default;
@@ -0,0 +1 @@
1
+ export default (ms = 0) => new Promise(r => {setTimeout(r, ms)})
@@ -77,15 +77,15 @@ const props = defineProps({
77
77
  },
78
78
  });
79
79
 
80
- store.setCoord(props.coord);
81
- store.setZoom(props.zoom);
82
- store.setZoomMin(props.zoomMin);
83
- store.setZoomMax(props.zoomMax);
84
- store.setDeviceZoom(props.deviceZoom);
85
- store.setMarkers(props.markers);
86
- store.setMarkerImage(props.markerImage);
87
- store.setMarkerActiveImage(props.markerActiveImage);
88
- store.setMarkerDisabledImage(props.markerDisabledImage);
80
+ store.coord = props.coord;
81
+ store.zoom = props.zoom;
82
+ store.zoomMin = props.zoomMin;
83
+ store.zoomMax = props.zoomMax;
84
+ store.deviceZoom = props.deviceZoom;
85
+ store.markers = props.markers;
86
+ store.markerImage = props.markerImage;
87
+ store.markerActiveImage = props.markerActiveImage;
88
+ store.markerDisabledImage = props.markerDisabledImage;
89
89
 
90
90
  watch(() => props.disabledMarkers, (v) => {
91
91
  store.setDisabledMarkers(v);
@@ -12,6 +12,7 @@
12
12
  import { ref } from 'vue';
13
13
  import UiLoading from '../../loading.vue';
14
14
  import { useMapStore } from '../store';
15
+ import wait from '../../helpers/wait';
15
16
 
16
17
  // Data
17
18
  const props = defineProps({
@@ -28,6 +29,7 @@
28
29
  type: Array
29
30
  },
30
31
  });
32
+ const emit = defineEmits(['error']);
31
33
  const store = useMapStore();
32
34
  const loading = ref(false);
33
35
  let cachedPosition = null;
@@ -65,7 +67,11 @@
65
67
  });
66
68
  }
67
69
 
70
+ let clickInProcess = false;
68
71
  async function handleClick() {
72
+ if (clickInProcess) return;
73
+ clickInProcess = true;
74
+
69
75
  try {
70
76
  // If cache not exist or it's older than 1 minute
71
77
  if (!cachedPosition || Date.now() - cachedTime > 60000) {
@@ -86,14 +92,24 @@
86
92
  );
87
93
 
88
94
  // Set coord and zoom
89
- store.setCoord(nearest.coord, 2);
90
- store.setZoom(nearest?.zoom ? nearest.zoom : 14);
95
+ // Pan to user location
96
+ store.setCoord(cachedPosition, 750);
97
+ store.setZoom(14, 750);
98
+
99
+ await wait(2000);
100
+
101
+ // Pan to nearest marker location
102
+ store.setCoord(nearest.coord, 1500);
103
+ store.setZoom(nearest?.zoom ? nearest.zoom : 14, 1500);
91
104
  } catch (err) {
92
105
  console.log('handleClick err', err);
106
+
107
+ emit('error', 'error-geo-not-enabled-on-device');
93
108
  }
94
109
 
95
110
  store.setSelectedMarker(null);
96
111
  loading.value = false;
112
+ clickInProcess = false;
97
113
  }
98
114
  </script>
99
115
 
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="component-ui-map-openlayer component-ui-map-engine">
2
+ <div class="component-ui-map-openlayer component-ui-map-engine" :class="{'tag-user-position': userCoord.length}">
3
3
  <div class="map" ref="refMap"></div>
4
4
  <div style="display:none">
5
5
  <div id="user-position-marker"></div>
@@ -61,8 +61,10 @@
61
61
  // Store
62
62
  const store = useMapStore();
63
63
  const {
64
+ cameraDuration,
64
65
  requestCoordChange,
65
66
  coord,
67
+ requestZoomChange,
66
68
  zoom,
67
69
  zoomMin,
68
70
  zoomMax,
@@ -84,18 +86,23 @@
84
86
  redrawMarkers();
85
87
  });
86
88
 
87
- // Watch coord
88
- watch([requestCoordChange, coord], (v) => {
89
- if (!v[0]) return;
89
+ // Watch coord or zoom change
90
+ watch([requestCoordChange, requestZoomChange], () => {
91
+ if (!requestCoordChange.value && !requestZoomChange.value) return;
90
92
 
91
- const coord = fromLonLat(v[1]);
93
+ console.log('Watch coord or zoom change');
92
94
 
93
- if (v[0] === 1)
94
- view.setCenter(coord);
95
- else
96
- view.animate({center: coord, duration: 300});
95
+ const options = {
96
+ duration: cameraDuration.value
97
+ };
97
98
 
98
- requestCoordChange.value = 0;
99
+ if (requestCoordChange.value) options.center = fromLonLat(coord.value);
100
+ if (requestZoomChange.value) options.zoom = zoom.value;
101
+
102
+ view.animate(options, () => {
103
+ requestCoordChange.value = false;
104
+ requestZoomChange.value = false;
105
+ });
99
106
  });
100
107
 
101
108
  // Watch user coord
@@ -103,20 +110,20 @@
103
110
  userPositionMarker.setPosition(fromLonLat(v));
104
111
  });
105
112
 
106
- // Watch zoom
107
- watch(zoom, (v) => {
108
- const currentZoom = view.getZoom();
113
+ // // Watch zoom
114
+ // watch(zoom, (v) => {
115
+ // const currentZoom = view.getZoom();
109
116
 
110
- if (currentZoom === v) return;
117
+ // if (currentZoom === v) return;
111
118
 
112
- if (initialized)
113
- view.animate({
114
- zoom: v,
115
- duration: 300
116
- });
117
- else
118
- view.setZoom(v);
119
- });
119
+ // if (initialized)
120
+ // view.animate({
121
+ // zoom: v,
122
+ // duration: 300
123
+ // });
124
+ // else
125
+ // view.setZoom(v);
126
+ // });
120
127
 
121
128
  const payload = {
122
129
  store,
@@ -339,8 +346,6 @@
339
346
  }, 50);
340
347
  });
341
348
 
342
- initialized = true;
343
-
344
349
  // Handle map marker click
345
350
  map.on('click', (e) => {
346
351
  cluster.getFeatures(e.pixel).then((clickedFeatures) => {
@@ -367,7 +372,12 @@
367
372
  });
368
373
  });
369
374
 
370
- map.on('loadend', () => { emit('initialized', payload); });
375
+ map.on('loadend', () => {
376
+ if (initialized) return;
377
+
378
+ initialized = true;
379
+ emit('initialized', payload);
380
+ });
371
381
  }
372
382
 
373
383
  // Hooks
@@ -468,6 +478,14 @@
468
478
 
469
479
  #user-position-marker {
470
480
  .mix-pulsar;
481
+
482
+ display: none;
483
+ }
484
+
485
+ &.tag-user-position {
486
+ #user-position-marker {
487
+ display: block;
488
+ }
471
489
  }
472
490
  }
473
491
  </style>
@@ -1,6 +1,8 @@
1
1
  export const useMapStore: import("pinia").StoreDefinition<"map", {
2
- requestCoordChange: number;
2
+ cameraDuration: number;
3
+ requestCoordChange: boolean;
3
4
  coord: never[];
5
+ requestZoomChange: boolean;
4
6
  zoom: number;
5
7
  zoomMin: number;
6
8
  zoomMax: number;
@@ -22,9 +24,10 @@ export const useMapStore: import("pinia").StoreDefinition<"map", {
22
24
  }, {
23
25
  /**
24
26
  * Set map zoom
25
- * @param {number} v
27
+ * @param {number} zoom
28
+ * @param {number} duration
26
29
  */
27
- setZoom(v: number): void;
30
+ setZoom(zoom: number, duration?: number): void;
28
31
  /**
29
32
  * Set min map zoom
30
33
  * @param {number} v
@@ -41,10 +44,10 @@ export const useMapStore: import("pinia").StoreDefinition<"map", {
41
44
  zoomOut(): void;
42
45
  /**
43
46
  * Set map coord
44
- * @param {MapCoord} v
45
- * @param {number} requestCoordChange - 1 default, 2 animated
47
+ * @param {number} coord
48
+ * @param {number} duration
46
49
  */
47
- setCoord(v: MapCoord, requestCoordChange?: number): void;
50
+ setCoord(coord: number, duration?: number): void;
48
51
  /**
49
52
  * Set user coord
50
53
  * @param {MapCoord} v
@@ -18,9 +18,10 @@ import { defineStore } from 'pinia';
18
18
  export const useMapStore = defineStore('map', {
19
19
  state: () => {
20
20
  return {
21
- requestCoordChange: 0,
21
+ cameraDuration: 0,
22
+ requestCoordChange: false,
22
23
  coord: [],
23
-
24
+ requestZoomChange: false,
24
25
  zoom: 8,
25
26
  zoomMin: 8,
26
27
  zoomMax: 18,
@@ -41,10 +42,13 @@ export const useMapStore = defineStore('map', {
41
42
  actions: {
42
43
  /**
43
44
  * Set map zoom
44
- * @param {number} v
45
+ * @param {number} zoom
46
+ * @param {number} duration
45
47
  */
46
- setZoom(v) {
47
- this.zoom = v;
48
+ setZoom(zoom, duration = 300) {
49
+ this.zoom = zoom;
50
+ this.cameraDuration = duration;
51
+ this.requestZoomChange = true;
48
52
  },
49
53
 
50
54
  /**
@@ -72,6 +76,8 @@ export const useMapStore = defineStore('map', {
72
76
  }
73
77
 
74
78
  this.zoom++;
79
+ this.cameraDuration = 300;
80
+ this.requestZoomChange = true;
75
81
  },
76
82
 
77
83
  /** Map zoom out */
@@ -83,16 +89,19 @@ export const useMapStore = defineStore('map', {
83
89
  }
84
90
 
85
91
  this.zoom--;
92
+ this.cameraDuration = 300;
93
+ this.requestZoomChange = true;
86
94
  },
87
95
 
88
96
  /**
89
97
  * Set map coord
90
- * @param {MapCoord} v
91
- * @param {number} requestCoordChange - 1 default, 2 animated
98
+ * @param {number} coord
99
+ * @param {number} duration
92
100
  */
93
- setCoord(v, requestCoordChange = 1) {
94
- this.requestCoordChange = requestCoordChange;
95
- this.coord = v;
101
+ setCoord(coord, duration = 300) {
102
+ this.coord = coord;
103
+ this.cameraDuration = duration;
104
+ this.requestCoordChange = true;
96
105
  },
97
106
 
98
107
  /**
@@ -1,9 +1,9 @@
1
1
  <template>
2
2
  <div class="component-ui-map-zoom">
3
3
  <div class="prepend"><slot /></div>
4
- <ui-button @click="store.zoomIn" color="gray" block variant="flat" size="small" shape="square">+</ui-button>
4
+ <ui-button @click="store.zoomIn" class="plus" color="gray" block variant="flat" size="small" shape="square">+</ui-button>
5
5
  <div class="separator"></div>
6
- <ui-button @click="store.zoomOut" color="gray" block variant="flat" size="small" shape="square">-</ui-button>
6
+ <ui-button @click="store.zoomOut" class="minus" color="gray" block variant="flat" size="small" shape="square">-</ui-button>
7
7
  </div>
8
8
  </template>
9
9
 
@@ -54,6 +54,16 @@ const props = defineProps(['store']);
54
54
  font-size: @com-text-large;
55
55
  }
56
56
 
57
+ .component-ui-button.plus .button-bg {
58
+ border-top-left-radius: @com-border-radius-default;
59
+ border-top-right-radius: @com-border-radius-default;
60
+ }
61
+
62
+ .component-ui-button.minus .button-bg {
63
+ border-bottom-left-radius: @com-border-radius-default;
64
+ border-bottom-right-radius: @com-border-radius-default;
65
+ }
66
+
57
67
  .separator {
58
68
  border-bottom: 1px solid @com-color-border;
59
69
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@community-release/nx-ui",
3
- "version": "0.0.33",
3
+ "version": "0.0.35",
4
4
  "description": "nx-ui - Nuxt UI library",
5
5
  "repository": {
6
6
  "type": "git",