@kahwee/sf-map-svg 1.4.1 → 1.5.0

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/CHANGELOG.md CHANGED
@@ -4,6 +4,11 @@ User-visible changes are recorded here. Unreleased entries describe changes on `
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ ## 1.5.0 — 2026-09-26
8
+
9
+ - Add `controls.neighborhoodPicker`, `controls.markerPicker`, `controls.help`, and `controls.status` so compact embeds can drop redundant chrome. Hidden help remains the map's accessible description; a hidden status line remains a polite live region; source attribution stays visible.
10
+ - Keep a configured `strings.chooseMarker` label after `setMarkers()` updates instead of reverting to “Choose marker”.
11
+
7
12
  ## 1.4.1 — 2026-09-26
8
13
 
9
14
  - Add a task-based example gallery and code recipes, with clearer routes among the Pages atlas, local measures, district history, transit, and lightweight map.
package/README.md CHANGED
@@ -255,7 +255,19 @@ aliases. Import types including `InteractiveSFMapOptions`, `InteractiveSFMapElem
255
255
  | `overlays` | `[]` | GeoJSON line or polygon overlays with stable IDs and optional SVG styles |
256
256
  | `style` | Built-in tokens | Explorer CSS tokens: `ink`, `surface`, `accent`, `border`, `focus`, `controlGap`, `font` |
257
257
  | `strings` | English defaults | Replace visible map labels and gesture help for localization |
258
- | `controls` | All enabled | Independently hide `zoom`, `pan`, `reset`, `labels`, `touch`, or `legend`; source attribution remains visible |
258
+ | `controls` | All enabled | Independently hide `zoom`, `pan`, `reset`, `labels`, `touch`, `legend`, `neighborhoodPicker`, `markerPicker`, `help`, or `status`; source attribution remains visible |
259
+
260
+ For a compact embed, hide the native choosers only when the page already lists every
261
+ marker or area as an accessible control. Hidden help remains the map's accessible
262
+ description, and a hidden status line remains a polite live region:
263
+
264
+ ```js
265
+ const map = createGuideMap({
266
+ interface: 'map',
267
+ controls: { labels: false, neighborhoodPicker: false, markerPicker: false, help: false, status: false },
268
+ strings: { chooseMarker: 'Place on map' }, // also used after setMarkers() updates
269
+ });
270
+ ```
259
271
 
260
272
  Explicit layer options override mode defaults even after `setMode()`. District fills, outlines,
261
273
  and badges can therefore be composed with neighborhood names without requiring district
@@ -30,6 +30,7 @@ function svgElement(tag, attributes = {}) {
30
30
  node.setAttribute(key, String(value));
31
31
  return node;
32
32
  }
33
+ let explorerCount = 0;
33
34
  /** Create an offline, browser-only neighborhood explorer. Call destroy() before disposal. */
34
35
  export function createNeighborhoodExplorerCore({ source = 'realtor', mode = 'neighborhoods', labels = true, neighborhood, year = 2022, theme = 'transit', interface: chrome = 'explorer', layers = {}, selectableNeighborhoods = true, labelSize = {}, fitPadding = 24, markers: initialMarkers = [], markerRadius = 6, markerHitSize = 44, markerColor = '#245b61', selectedMarkerColor = '#f04f32', onMarkerActivate, overlays: initialOverlays = [], onOverlayActivate, style: styleOptions = {}, strings = {}, controls = {}, } = {}, data) {
35
36
  if (!['neighborhoods', 'districts', 'basemap'].includes(mode))
@@ -141,6 +142,7 @@ export function createNeighborhoodExplorerCore({ source = 'realtor', mode = 'nei
141
142
  .sf-explorer-hint{padding:6px 16px 10px;font-size:12px;color:#586f80;background:#fff}
142
143
  .sf-explorer text{pointer-events:none}
143
144
  .sf-explorer-status{padding:0 16px 14px;font-size:12px;background:#fff;color:#496578}
145
+ .sf-explorer-visually-hidden{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}
144
146
  .sf-explorer[data-interface=map] .sf-explorer-body{display:block}
145
147
  .sf-explorer[data-interface=map] .sf-explorer-header,.sf-explorer[data-interface=map] .sf-explorer-panel,.sf-explorer[data-interface=map] .sf-explorer-detail{display:none}
146
148
  .sf-explorer-feature-controls{display:flex;flex-wrap:wrap;gap:8px;padding:10px;background:#fff}
@@ -222,6 +224,7 @@ export function createNeighborhoodExplorerCore({ source = 'realtor', mode = 'nei
222
224
  const canvas = element('div', '', 'sf-explorer-canvas');
223
225
  const hint = element('p', strings.gestureHelp ??
224
226
  'Drag to pan · Ctrl/⌘ + scroll to zoom · Focus map: arrows pan, +/− zoom, Home resets. Touch: scroll the page, or enable Touch navigation to pan and pinch the map. Escape exits.', 'sf-explorer-hint');
227
+ hint.id = `sf-explorer-help-${++explorerCount}`;
225
228
  const status = element('p', '', 'sf-explorer-status');
226
229
  status.setAttribute('aria-live', 'polite');
227
230
  const legend = element('div', '', 'sf-explorer-legend');
@@ -764,12 +767,19 @@ export function createNeighborhoodExplorerCore({ source = 'realtor', mode = 'nei
764
767
  ? `${year} supervisorial districts. Numbers identify each district.`
765
768
  : `${formatSourceLabel(source)}. Select a neighborhood to begin.`;
766
769
  }
770
+ function syncFeatureControls() {
771
+ featureControls.hidden = neighborhoodLabel.hidden && markerLabel.hidden;
772
+ }
767
773
  function updateComposition() {
768
774
  const neighborhoodsVisible = enabled('neighborhoodLines') || (labels && enabled('neighborhoodLabels'));
769
775
  areas.style.display = neighborhoodsVisible ? '' : 'none';
770
776
  areas.style.pointerEvents = selectableNeighborhoods ? '' : 'none';
771
777
  neighborhoodLabel.hidden =
772
- !neighborhoodsVisible || !selectableNeighborhoods || chrome === 'explorer';
778
+ !neighborhoodsVisible ||
779
+ !selectableNeighborhoods ||
780
+ chrome === 'explorer' ||
781
+ controls.neighborhoodPicker === false;
782
+ syncFeatureControls();
773
783
  for (const item of items) {
774
784
  item.node.setAttribute('stroke-width', item.feature === selected ? '2.2' : enabled('neighborhoodLines') ? '.55' : '0');
775
785
  item.node.setAttribute('tabindex', selectableNeighborhoods && item === items[0] ? '0' : '-1');
@@ -881,9 +891,10 @@ export function createNeighborhoodExplorerCore({ source = 'realtor', mode = 'nei
881
891
  markerSelect.append(option);
882
892
  return { marker, point, node, dot, hit };
883
893
  });
884
- markerLabel.hidden = !markerItems.length;
894
+ markerLabel.hidden = !markerItems.length || controls.markerPicker === false;
885
895
  if (markerLabel.firstChild)
886
- markerLabel.firstChild.textContent = `Choose marker (${markerItems.length})`;
896
+ markerLabel.firstChild.textContent = `${strings.chooseMarker ?? 'Choose marker'} (${markerItems.length})`;
897
+ syncFeatureControls();
887
898
  const nextSelection = previous && ids.has(previous)
888
899
  ? previous
889
900
  : (markers.find((marker) => marker.selected)?.id ?? null);
@@ -902,6 +913,13 @@ export function createNeighborhoodExplorerCore({ source = 'realtor', mode = 'nei
902
913
  labelsButton.hidden = true;
903
914
  if (controls.legend === false)
904
915
  legend.hidden = true;
916
+ if (controls.help === false) {
917
+ // The instructions stay available to assistive technology as the map's description.
918
+ hint.hidden = true;
919
+ svg.setAttribute('aria-describedby', hint.id);
920
+ }
921
+ if (controls.status === false)
922
+ status.classList.add('sf-explorer-visually-hidden');
905
923
  function setMode(next) {
906
924
  if (destroyed)
907
925
  return;
@@ -101,7 +101,12 @@ export interface NeighborhoodExplorerOptions {
101
101
  /** Stable theme tokens consumed by the explorer chrome. */
102
102
  style?: Partial<Record<'ink' | 'surface' | 'accent' | 'border' | 'focus' | 'controlGap' | 'font', string>>;
103
103
  strings?: Partial<Record<'title' | 'mode' | 'source' | 'search' | 'chooseNeighborhood' | 'chooseMarker' | 'touchNavigation' | 'reset' | 'emptyResults' | 'gestureHelp', string>>;
104
- controls?: Partial<Record<'zoom' | 'pan' | 'reset' | 'labels' | 'touch' | 'legend', boolean>>;
104
+ /**
105
+ * Independently hide chrome. `neighborhoodPicker` and `markerPicker` hide the native
106
+ * choosers (supply your own accessible list); `help` keeps the gesture help as the map's
107
+ * accessible description; `status` keeps a visually hidden live region. Attribution stays.
108
+ */
109
+ controls?: Partial<Record<'zoom' | 'pan' | 'reset' | 'labels' | 'touch' | 'legend' | 'neighborhoodPicker' | 'markerPicker' | 'help' | 'status', boolean>>;
105
110
  }
106
111
  export interface NeighborhoodExplorerElement extends HTMLElement {
107
112
  selectNeighborhood(name: string | null, options?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kahwee/sf-map-svg",
3
- "version": "1.4.1",
3
+ "version": "1.5.0",
4
4
  "description": "Offline SVG maps of San Francisco with district boundaries, parks, landmarks, and BART stations.",
5
5
  "type": "module",
6
6
  "main": "./dist/src/index.js",