@aiaiai-pt/design-system 0.5.4 → 0.5.6

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,40 @@
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} — Cluster source */
48
+ let _clusterSource = $state();
49
+ /** @type {any} — Feature constructor */
50
+ let _Feature;
51
+ /** @type {any} — Point constructor */
52
+ let _Point;
53
+
54
+ // Reactive: animate to new center/zoom when props change
55
+ $effect(() => {
56
+ if (!_map) return;
57
+ const view = _map.getView();
58
+ if (!view) return;
59
+ const targetCenter = fromLonLat(center);
60
+ view.animate({ center: targetCenter, zoom, duration: 300 });
61
+ });
62
+
63
+ // Reactive: update markers when props change
64
+ $effect(() => {
65
+ if (!_vectorSource || !_Feature || !_Point) return;
66
+ const features = markers.map(m => {
67
+ const f = new _Feature({ geometry: new _Point(fromLonLat([m.lon, m.lat])) });
68
+ f.set('markerData', m);
69
+ return f;
70
+ });
71
+ _vectorSource.clear();
72
+ _vectorSource.addFeatures(features);
73
+ _clusterSource?.refresh();
74
+ });
75
+
42
76
  $effect(() => {
43
77
  if (!container) return;
44
78
 
@@ -86,6 +120,12 @@
86
120
  const vectorSource = new VectorSource({ features });
87
121
  const clusterSource = new Cluster({ distance, source: vectorSource });
88
122
 
123
+ // Store refs for reactive effects
124
+ _vectorSource = vectorSource;
125
+ _clusterSource = clusterSource;
126
+ _Feature = Feature;
127
+ _Point = Point;
128
+
89
129
  const clusterLayer = new VectorLayer({
90
130
  source: clusterSource,
91
131
  style: (feature) => {
@@ -133,6 +173,7 @@
133
173
  zoom,
134
174
  }),
135
175
  });
176
+ _map = map;
136
177
 
137
178
  // Hover: show tooltip
138
179
  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.6",
4
4
  "description": "Design system tokens and Svelte components for aiaiai products",
5
5
  "license": "MIT",
6
6
  "type": "module",