@aiaiai-pt/design-system 0.5.4 → 0.5.5

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.
@@ -39,6 +39,37 @@
39
39
  /** @type {HTMLElement | undefined} */
40
40
  let container = $state();
41
41
 
42
+ // Hoisted references for reactive effects
43
+ /** @type {import('ol/Map.js').default | undefined} */
44
+ let _map = $state();
45
+ /** @type {any} — VectorSource */
46
+ let _vectorSource = $state();
47
+ /** @type {any} — Feature constructor */
48
+ let _Feature;
49
+ /** @type {any} — Point constructor */
50
+ let _Point;
51
+
52
+ // Reactive: animate to new center/zoom when props change
53
+ $effect(() => {
54
+ if (!_map) return;
55
+ const view = _map.getView();
56
+ if (!view) return;
57
+ const targetCenter = fromLonLat(center);
58
+ view.animate({ center: targetCenter, zoom, duration: 300 });
59
+ });
60
+
61
+ // Reactive: update markers when props change
62
+ $effect(() => {
63
+ if (!_vectorSource || !_Feature || !_Point) return;
64
+ const features = markers.map(m => {
65
+ const f = new _Feature({ geometry: new _Point(fromLonLat([m.lon, m.lat])) });
66
+ f.set('markerData', m);
67
+ return f;
68
+ });
69
+ _vectorSource.clear();
70
+ _vectorSource.addFeatures(features);
71
+ });
72
+
42
73
  $effect(() => {
43
74
  if (!container) return;
44
75
 
@@ -86,6 +117,11 @@
86
117
  const vectorSource = new VectorSource({ features });
87
118
  const clusterSource = new Cluster({ distance, source: vectorSource });
88
119
 
120
+ // Store refs for reactive effects
121
+ _vectorSource = vectorSource;
122
+ _Feature = Feature;
123
+ _Point = Point;
124
+
89
125
  const clusterLayer = new VectorLayer({
90
126
  source: clusterSource,
91
127
  style: (feature) => {
@@ -133,6 +169,7 @@
133
169
  zoom,
134
170
  }),
135
171
  });
172
+ _map = map;
136
173
 
137
174
  // Hover: show tooltip
138
175
  map.on('pointermove', (evt) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiaiai-pt/design-system",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
4
4
  "description": "Design system tokens and Svelte components for aiaiai products",
5
5
  "license": "MIT",
6
6
  "type": "module",