@smartnet360/svelte-components 0.0.79 → 0.0.80

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.
@@ -33,6 +33,10 @@
33
33
  actionButtonLabel?: string;
34
34
  /** Feature icon (default: geo-alt-fill) */
35
35
  featureIcon?: string;
36
+ /** Available property names to use as ID (default: ['id', 'siteId', 'cellName']) */
37
+ idPropertyOptions?: string[];
38
+ /** Default property to use as ID (default: 'id') */
39
+ defaultIdProperty?: string;
36
40
  }
37
41
 
38
42
  let {
@@ -42,7 +46,9 @@
42
46
  iconOnlyWhenCollapsed = true,
43
47
  onAction,
44
48
  actionButtonLabel = 'Process',
45
- featureIcon = 'geo-alt-fill'
49
+ featureIcon = 'geo-alt-fill',
50
+ idPropertyOptions = ['siteId', 'cellName','id'],
51
+ defaultIdProperty = 'siteId'
46
52
  }: Props = $props();
47
53
 
48
54
  // Get map from context
@@ -53,6 +59,9 @@
53
59
  const store = createFeatureSelectionStore();
54
60
  console.log('[FeatureSelectionControl] Store created:', store);
55
61
 
62
+ // Set the ID property to use
63
+ store.setIdProperty(defaultIdProperty);
64
+
56
65
  let selectedFeatures = $derived(store.getSelectedFeatures());
57
66
  let selectionCount = $derived(store.count);
58
67
  let hasSelection = $derived(selectionCount > 0);
@@ -86,6 +95,12 @@
86
95
  store.toggleSelectionMode();
87
96
  }
88
97
 
98
+ function handleIdPropertyChange(event: Event) {
99
+ const target = event.target as HTMLSelectElement;
100
+ store.setIdProperty(target.value);
101
+ console.log('[FeatureSelectionControl] ID property changed to:', target.value);
102
+ }
103
+
89
104
  function handleRemoveFeature(featureId: string) {
90
105
  store.removeFeatureSelection(featureId);
91
106
  }
@@ -138,6 +153,21 @@
138
153
  {/if}
139
154
  </div>
140
155
 
156
+ <!-- ID Property Selector -->
157
+ <div class="mb-3">
158
+ <label for="id-property-select" class="form-label small">Select By</label>
159
+ <select
160
+ id="id-property-select"
161
+ class="form-select form-select-sm"
162
+ value={store.idProperty}
163
+ onchange={handleIdPropertyChange}
164
+ >
165
+ {#each idPropertyOptions as option}
166
+ <option value={option}>{option}</option>
167
+ {/each}
168
+ </select>
169
+ </div>
170
+
141
171
  <!-- Selection Stats -->
142
172
  <div class="selection-stats mb-2">
143
173
  <strong>{selectionCount}</strong>
@@ -13,6 +13,10 @@ interface Props {
13
13
  actionButtonLabel?: string;
14
14
  /** Feature icon (default: geo-alt-fill) */
15
15
  featureIcon?: string;
16
+ /** Available property names to use as ID (default: ['id', 'siteId', 'cellName']) */
17
+ idPropertyOptions?: string[];
18
+ /** Default property to use as ID (default: 'id') */
19
+ defaultIdProperty?: string;
16
20
  }
17
21
  declare const FeatureSelectionControl: import("svelte").Component<Props, {}, "">;
18
22
  type FeatureSelectionControl = ReturnType<typeof FeatureSelectionControl>;
@@ -16,12 +16,17 @@ export declare class FeatureSelectionStore {
16
16
  private selectedFeatures;
17
17
  private map;
18
18
  selectionMode: boolean;
19
+ idProperty: string;
19
20
  private clickHandler;
20
21
  constructor();
21
22
  /**
22
23
  * Initialize the store with a map instance
23
24
  */
24
25
  setMap(mapInstance: MapboxMap): void;
26
+ /**
27
+ * Set which property to use as the ID
28
+ */
29
+ setIdProperty(property: string): void;
25
30
  /**
26
31
  * Setup global click handler for any feature
27
32
  */
@@ -8,6 +8,7 @@ export class FeatureSelectionStore {
8
8
  selectedFeatures = $state([]);
9
9
  map = $state(null);
10
10
  selectionMode = $state(false);
11
+ idProperty = $state('siteId'); // Default property to use as ID
11
12
  clickHandler = null;
12
13
  constructor() { }
13
14
  /**
@@ -18,6 +19,13 @@ export class FeatureSelectionStore {
18
19
  this.map = mapInstance;
19
20
  this.setupClickHandler();
20
21
  }
22
+ /**
23
+ * Set which property to use as the ID
24
+ */
25
+ setIdProperty(property) {
26
+ this.idProperty = property;
27
+ console.log('[FeatureSelection] ID property set to:', property);
28
+ }
21
29
  /**
22
30
  * Setup global click handler for any feature
23
31
  */
@@ -39,16 +47,17 @@ export class FeatureSelectionStore {
39
47
  properties: feature.properties,
40
48
  id: feature.id
41
49
  });
42
- const featureId = feature.properties?.id || feature.id;
50
+ // Use the configured property as the ID
51
+ const featureId = feature.properties?.[this.idProperty] || feature.id;
43
52
  const siteId = feature.properties?.siteId;
44
53
  const cellName = feature.properties?.cellName;
45
54
  if (featureId) {
46
- console.log('[FeatureSelection] Found feature with ID:', featureId, 'siteId:', siteId, 'cellName:', cellName);
55
+ console.log('[FeatureSelection] Found feature with ID (using', this.idProperty + '):', featureId, 'siteId:', siteId, 'cellName:', cellName);
47
56
  this.toggleFeatureSelection(String(featureId), feature.layer?.id, feature.properties || undefined, siteId, cellName);
48
57
  break; // Only select the topmost feature
49
58
  }
50
59
  else {
51
- console.log('[FeatureSelection] Feature has no id property');
60
+ console.log('[FeatureSelection] Feature has no', this.idProperty, 'property');
52
61
  }
53
62
  }
54
63
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartnet360/svelte-components",
3
- "version": "0.0.79",
3
+ "version": "0.0.80",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run prepack",